From 6b88ceb65e8a1d8dea826f2c930aca909065407f Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Mon, 25 May 2009 22:01:27 -0400 Subject: [PATCH] use mysqli_fetch_all if it's available --- framework/Db/lib/Horde/Db/Adapter/Mysqli.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysqli.php b/framework/Db/lib/Horde/Db/Adapter/Mysqli.php index 9d91e8236..19a587e9f 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysqli.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysqli.php @@ -42,6 +42,11 @@ class Horde_Db_Adapter_Mysqli extends Horde_Db_Adapter_Abstract */ protected $_schemaClass = 'Horde_Db_Adapter_Mysql_Schema'; + /** + * @var boolean + */ + protected $_hasMysqliFetchAll = false; + /*########################################################################## # Public @@ -145,6 +150,8 @@ class Horde_Db_Adapter_Mysqli extends Horde_Db_Adapter_Abstract if (!empty($config['charset'])) { $this->setCharset($config['charset']); } + + $this->_hasMysqliFetchAll = function_exists('mysqli_fetch_all'); } /** @@ -215,10 +222,14 @@ class Horde_Db_Adapter_Mysqli extends Horde_Db_Adapter_Abstract public function selectAll($sql, $arg1=null, $arg2=null) { $result = $this->execute($sql, $arg1, $arg2); - $rows = array(); - if ($result) { - while ($row = $result->fetch_array()) { - $rows[] = $row; + if ($this->_hasMysqliFetchAll) { + return $result->fetch_all(MYSQLI_BOTH); + } else { + $rows = array(); + if ($result) { + while ($row = $result->fetch_array()) { + $rows[] = $row; + } } } return $rows; -- 2.11.0