MySQL developes a new driver for PHP, called php-mysqlnd.
This driver is a replacement for libmysql, but offers some new
features too.
The result-object now has the method "fetch_all", which (as the
name says) returns an array containing all result set rows. This
method is much faster than calling fetch_assoc in a loop.
Unfortunately it´s not possible to specify a column that should
be used for the array index.
Would be great if something like this is possible:
$res = $mysqli->query("SELECT customer_id, last_name FROM customers");
$data = $res->fetch_all("customer_id");
print_r($data);
Array
(
[123] => Array
(
[customer_id] => 123
[last_name] => foo
)
[124] => Array
(
[customer_id] => 124
[last_name] …[Read more]