From:             adamhunger at yahoo dot com
Operating system: freebsd4.7 (i386)
PHP version:      Irrelevant
PHP Bug Type:     MySQL related
Bug description:  mysql_field_table multiple columns

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
)


-- 
Edit bug report at http://bugs.php.net/?id=30171&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30171&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30171&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30171&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30171&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30171&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30171&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30171&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30171&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30171&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30171&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30171&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30171&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30171&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30171&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30171&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30171&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30171&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30171&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30171&r=mysqlcfg

Reply via email to