|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-03-07 17:50 UTC] olafvdspek at gmail dot com
Description:
------------
PDO supports this, it'd be nice if mysqli itself supported this as well.
Test script:
---------------
$mysqli = new mysqli('', 'pdo', '123', 'pdo');
foreach ($mysqli->query("select uid, name from users") as [$uid, $name]) // 3
print("$uid: $name\n");
Actual result:
--------------
// PHP Warning: Undefined array key 0 on line 3
// PHP Warning: Undefined array key 1 on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 20:00:01 2025 UTC |
Hint: foreach ($mysqli->query("select uid, name from users") as $row) print_r($row);// mysqli Array ( [uid] => 1 [name] => Alpha ) // PDO Array ( [uid] => 1 [0] => 1 [name] => Alpha [1] => Alpha )