note 99555 added to pdostatement.fetch

From: Date: Tue, 24 Aug 2010 13:51:49 +0000
Subject: note 99555 added to pdostatement.fetch
Groups: php.notes 
Request: Send a blank email to php-notes+get-171983@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 20.142.112.35 ---- Manual Page -- http://www.php.net/manual/en/pdostatement.fetch.php Edit -- https://master.php.net/note/edit/99555 Del: integrated -- https://master.php.net/note/delete/99555/integrated Del: useless -- https://master.php.net/note/delete/99555/useless Del: bad code -- https://master.php.net/note/delete/99555/bad+code Del: spam -- https://master.php.net/note/delete/99555/spam Del: non-english -- https://master.php.net/note/delete/99555/non-english Del: in docs -- https://master.php.net/note/delete/99555/in+docs Del: other reasons-- https://master.php.net/note/delete/99555 Reject -- https://master.php.net/note/reject/99555 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171983) next »