From 7b97eaa6f0914c9d0980f84dec88a5fb70f64f2e Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Wed, 19 Dec 2007 15:22:36 +0000 Subject: [PATCH] added missing examples and some functionality --- libraries/database_interface.lib.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 8b32023b4..d362c4755 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -981,6 +981,16 @@ function PMA_DBI_fetch_single_row($result, $type = 'ASSOC', $link = null, $optio * $users = PMA_DBI_fetch_result($sql); * // produces * // $users[] = 'John Doe' + * + * $sql = 'SELECT `group`, `name` FROM `user`' + * $users = PMA_DBI_fetch_result($sql, array('group', null), 'name'); + * // produces + * // $users['admin'][] = 'John Doe' + * + * $sql = 'SELECT `group`, `name` FROM `user`' + * $users = PMA_DBI_fetch_result($sql, array('group', 'name'), 'id'); + * // produces + * // $users['admin']['John Doe'] = '123' * * * @uses is_string() @@ -1040,6 +1050,11 @@ function PMA_DBI_fetch_result($result, $key = null, $value = null, while ($row = $fetch_function($result)) { $result_target =& $resultrows; foreach ($key as $key_index) { + if (null === $key_index) { + $result_target =& $result_target[]; + continue; + } + if (! isset($result_target[$row[$key_index]])) { $result_target[$row[$key_index]] = array(); } @@ -1057,6 +1072,11 @@ function PMA_DBI_fetch_result($result, $key = null, $value = null, while ($row = $fetch_function($result)) { $result_target =& $resultrows; foreach ($key as $key_index) { + if (null === $key_index) { + $result_target =& $result_target[]; + continue; + } + if (! isset($result_target[$row[$key_index]])) { $result_target[$row[$key_index]] = array(); }