Req #80844 [Opn->Nab]: Array destructuring for mysqli_result
| From: | requinix@php.net | Date: | Sun, 07 Mar 2021 23:00:44 +0000 |
| Subject: | Req #80844 [Opn->Nab]: Array destructuring for mysqli_result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232611@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80844&edit=1
ID: 80844
Updated by: requinix@php.net
Reported by: olafvdspek at gmail dot com
Summary: Array destructuring for mysqli_result
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: MySQLi related
Operating System: *
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Hint:
foreach ($mysqli->query("select uid, name from users") as $row)
print_r($row);
Previous Comments:
------------------------------------------------------------------------
[2021-03-07 17:50:27] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80844&edit=1