note 56031 added to function.pdostatement-fetchall
| From: | f dot kowal at wp dot pl | Date: | Sun, 21 Aug 2005 10:10:22 +0000 |
| Subject: | note 56031 added to function.pdostatement-fetchall | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93981@lists.php.net to get a copy of this message | ||
it could be usefull if one could specify a parameter, telling what is to be the index of the return
array
something like:
$sth = $dbh->prepare("SELECT id_fruit, name, colour FROM fruit");
$sth->execute();
/* Fetch all of the remaining rows in the result set */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll('id_fruit');
print_r($result);
and the result would be like:
Array
(
[115] => Array
(
[id_fruit] => 115
[0] => 115
[NAME] => pear
[1] => pear
[COLOUR] => green
[2] => green
)
[44] => Array
(
[id_fruit] => 44
[0] => 44
[NAME] => watermelon
[1] => watermelon
[COLOUR] => pink
[2] => pink
)
)
ofcourse if the table_index would not be specified the result array elements would be assigned auto
incremented values
----
Manual Page -- http://www.php.net/manual/en/function.pdostatement-fetchall.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56031
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56031&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56031&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56031&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56031&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56031&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56031&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56031&report=yes
Search -- http://master.php.net/manage/user-notes.php