php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #30171 MYSQL: mysql_field_table multiple columns
Submitted: 2004-09-20 19:11 UTC Modified: 2016-11-23 13:35 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: adamhunger at yahoo dot com Assigned: cmb (profile)
Status: Closed Package: MySQL related
PHP Version: Irrelevant OS: freebsd4.7 (i386)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: adamhunger at yahoo dot com
New email:
PHP Version: OS:

 

 [2004-09-20 19:11 UTC] adamhunger at yahoo dot com
Description:
------------
mysql_field_table does not return the correct table name when two tables are used.  (Note: I'm not using table aliases.)



Reproduce code:
---------------
A simple query such as:

         SELECT partners.buyer,
                calls_nc_sell_daily.market,
                partners.name,
                calls_nc_sell_daily.partner_id_fk as 'partners_id_fk',
                partners.seller
           FROM partners, calls_nc_sell_daily
          WHERE calls_nc_sell_daily.date >= '$date_start'
            AND calls_nc_sell_daily.date <= '$date_stop'
            AND partners.id = calls_nc_sell_daily.partner_id_fk

WHEN result field parsed by following PHP fragment:

$tables = array();
for($i=0;$i<$elements;$i++) {
   $name =  mysql_field_name($result,$i);
   $tables[$name] = mysql_field_table($result,$name);
}
print_r($tables);


Expected result:
----------------
Array
(
    [buyer] => partners
    [market] => calls_nc_sell_daily
    [name] => partners
    [partners_id_fk] => calls_nc_sell_daily
    [seller] => partners
)


Actual result:
--------------
Array
(
    [buyer] => partners
    [market] => partners
    [name] => partners
    [partners_id_fk] => partners
    [seller] => partners
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 23:43 UTC] jani@php.net
-Package: Feature/Change Request +Package: MySQL related
 [2016-11-23 13:35 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-11-23 13:35 UTC] cmb@php.net
The MySSQL extension (ext/mysql) has been deprecated as of PHP
5.5.0 and removed as of PHP 7.0.0, so we won't implement any
feature requests anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC