From: Jan Schneider Date: Tue, 1 Feb 2011 15:10:34 +0000 (+0100) Subject: Add columnCount() to native mysql drivers. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c961b720e6f7230b6934a9b16baacc8abe0f6725;p=horde.git Add columnCount() to native mysql drivers. --- diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysql/Result.php b/framework/Db/lib/Horde/Db/Adapter/Mysql/Result.php index 873589145..7141d86f5 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysql/Result.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysql/Result.php @@ -214,4 +214,17 @@ class Horde_Db_Adapter_Mysql_Result implements Iterator Horde_Db::FETCH_BOTH => MYSQL_BOTH); $this->_fetchMode = $map[$fetchmode]; } + + /** + * Returns the number of columns in the result set + * + * @return integer Number of columns. + */ + public function columnCount() + { + if (is_null($this->_result)) { + $this->rewind(); + } + return mysql_num_fields($this->_result); + } } diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysqli/Result.php b/framework/Db/lib/Horde/Db/Adapter/Mysqli/Result.php index 9318bb22d..40c5e338f 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysqli/Result.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysqli/Result.php @@ -214,4 +214,17 @@ class Horde_Db_Adapter_Mysqli_Result implements Iterator Horde_Db::FETCH_BOTH => MYSQL_BOTH); $this->_fetchMode = $map[$fetchmode]; } + + /** + * Returns the number of columns in the result set + * + * @return integer Number of columns. + */ + public function columnCount() + { + if (is_null($this->_result)) { + $this->rewind(); + } + return $this->_result->field_count; + } }