note 99555 deleted from pdostatement.fetch by danbrown

From: Date: Fri, 12 Nov 2010 12:13:01 +0000
Subject: note 99555 deleted from pdostatement.fetch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173970@lists.php.net to get a copy of this message
Note Submitter: nospam9874987ekjf at gmail dot com ---- Left join gotcha: Concatenating two tables in the result of an sql select statement and fetching with the associative array result will cause any duplicate fields to be clobbered. Example: SELECT t1.*,t2.* from t1 left join t2 if t1 and t2 have same field names and t2 results don't exist, the values for the field names in t1 returned will be clobbered by the nulls returned for t2 that have the same field names because in an associative array, those names are the indexes and they are not duplicated. The LEFT JOIN returns all fields from t1 even if there are no t2 records, however it appears that the empty or null values are returned for the non-existant t2 record and filled into the result array - BUT since the array is associative, any field names in t2 that match field names in t1 will cause the null to overwrite the t1 field value with the same name.

« previous php.notes (#173970) next »