ID:               48151
 Updated by:       j...@php.net
 Reported By:      mail at danhofnann dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         PDO related
 Operating System: Linux
 PHP Version:      5.2.9
 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.




Previous Comments:
------------------------------------------------------------------------

[2009-05-05 07:26:45] mail at danhofnann dot com

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 this bug report at http://bugs.php.net/?id=48151&edit=1

Reply via email to