]> granicus.if.org Git - php/commit
Another nice new function that comes with mysqlnd: return all rows of
authorUlf Wendel <uw@php.net>
Mon, 23 Jul 2007 12:27:39 +0000 (12:27 +0000)
committerUlf Wendel <uw@php.net>
Mon, 23 Jul 2007 12:27:39 +0000 (12:27 +0000)
commit16008bc577f30de1f13ae15b34a6efe4e257fe49
tree7e9297d0c2f95217f9780d7407f3a95ac1bd62b1
parentff87d3ec5b2ccc1555d669cbe5f5a90ba5885068
Another nice new function that comes with mysqlnd: return all rows of
a result set in one array. This is handy if want to fetch all results and
pass the data directly to a template engine, for example. In this case
you save a loop.

1) Currently:
  $all_rows = array();
  while ($row = mysqli_fetch_assoc($res))
   $all_rows[] = $row;

2) With mysqli_fetch_all:
  $all_rows = mysqli_fetch_all($res, MYSQL_ASSOC)

Note: if you need the loop for processing each row, try variant 1) for
performance reasons.
ext/mysqli/tests/mysqli_fetch_all.phpt [new file with mode: 0644]
ext/mysqli/tests/mysqli_fetch_all_oo.phpt [new file with mode: 0644]