note 121997 added to mysqli-result.fetch-assoc

From: Date: Thu, 07 Dec 2017 20:24:27 +0000
Subject: note 121997 added to mysqli-result.fetch-assoc
Groups: php.notes 
Request: Send a blank email to php-notes+get-209336@lists.php.net to get a copy of this message
Be careful when using fetch_assoc instead of fetch_row. If two columns of the result have the same column name, even if they are prefixed with different table names in the query, only one of them will be retained in the result. This is because the prefix is dropped (either by mysql or by this function) For example if the query is select p1.name, p2.name from person p1, friend, person p2 where p1.id = friend.person1 and p2.id = friend.person2 the arrays returned by fetch_assoc will be of the form {'name' => 'bob'} {'name' => 'anna'} and not (as expected) {'p1.name' => 'bob', 'p2.name' => 'alice'} {'p1.name' => 'anna', 'p2.name' => 'irla'} ---- Server IP: 208.43.231.9 Probable Submitter: 89.217.29.81 ---- Manual Page -- http://php.net/manual/en/mysqli-result.fetch-assoc.php Edit -- https://master.php.net/note/edit/121997 Del: integrated -- https://master.php.net/note/delete/121997/integrated Del: useless -- https://master.php.net/note/delete/121997/useless Del: bad code -- https://master.php.net/note/delete/121997/bad+code Del: spam -- https://master.php.net/note/delete/121997/spam Del: non-english -- https://master.php.net/note/delete/121997/non-english Del: in docs -- https://master.php.net/note/delete/121997/in+docs Del: other reasons-- https://master.php.net/note/delete/121997 Reject -- https://master.php.net/note/reject/121997 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209336) next »