From: mail at danhofnann dot com
Operating system: Linux
PHP version: 5.2.9
PHP Bug Type: PDO related
Bug description: Joining key returns as blank when key is used in OUT LEFT
JOIN
Description:
------------
If you do an OUTER LEFT JOIN and set PDO FetchALL to PDO::FETCH_ASSOC, any
primary keys you used in the OUTER LEFT JOIN will be set to a blank if
there are no records returned in the JOIN.
If we are joining using a field called "product_id" from a product table
to an image table using an outer left join, and no records exist for that
"product_id" in the image table, the product id comes back as blank in the
resulting array
Reproduce code:
---------------
//query the product table and join to the image table and return any
images, if we have any, for each product. Assume the image table contains
no records
$sql = "SELECT * FROM product, image
LEFT OUTER JOIN image ON (product.product_id = image.product_id)";
$array = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r($array);
?>
Expected result:
----------------
Array
(
[0] => Array
(
[product_id] => 16
[notes] => "this product..."
[brand] => "Best Yet"
...
Actual result:
--------------
Array
(
[0] => Array
(
[product_id] =>
[notes] => "this product..."
[brand] => "Best Yet"
...
--
Edit bug report at http://bugs.php.net/?id=48151&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48151&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48151&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48151&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48151&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48151&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48151&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48151&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48151&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48151&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48151&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48151&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48151&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48151&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48151&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48151&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48151&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48151&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48151&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48151&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48151&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48151&r=mysqlcfg