summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-07-05 21:04:31 +0200
committerAndrey Andreev <narf@bofh.bg>2012-07-05 21:04:31 +0200
commitd74e027614fd1d5209180800e97bb8a01e5d4acf (patch)
treea079e66009f0700bc39d38c6727eb8c049f2e595 /system/database/drivers
parent92d18a7b6c46eadc9db58ca60ffce3980e2313ff (diff)
parent9e3a83a65668cc26b685f0b35a4428809435f7c9 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into feature/db_subdrivers
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/mysql/mysql_result.php25
-rw-r--r--system/database/drivers/pdo/pdo_driver.php17
2 files changed, 35 insertions, 7 deletions
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index b507f7960..a75cfad1f 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -38,15 +38,30 @@
class CI_DB_mysql_result extends CI_DB_result {
/**
+ * Constructor
+ *
+ * @param object
+ * @return void
+ */
+ public function __construct(&$driver_object)
+ {
+ parent::__construct($driver_object);
+
+ // Required, due to mysql_data_seek() causing nightmares
+ // with empty result sets
+ $this->num_rows = @mysql_num_rows($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Number of rows in the result set
*
* @return int
*/
public function num_rows()
{
- return is_int($this->num_rows)
- ? $this->num_rows
- : $this->num_rows = @mysql_num_rows($this->result_id);
+ return $this->num_rows;
}
// --------------------------------------------------------------------
@@ -135,7 +150,9 @@ class CI_DB_mysql_result extends CI_DB_result {
*/
protected function _data_seek($n = 0)
{
- return @mysql_data_seek($this->result_id, $n);
+ return $this->num_rows
+ ? @mysql_data_seek($this->result_id, $n)
+ : FALSE;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index dcae1a591..26ad3831a 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -154,9 +154,20 @@ class CI_DB_pdo_driver extends CI_DB {
*/
public function version()
{
- return isset($this->data_cache['version'])
- ? $this->data_cache['version']
- : $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
+ if (isset($this->data_cache['version']))
+ {
+ return $this->data_cache['version'];
+ }
+
+ // Not all subdrivers support the getAttribute() method
+ try
+ {
+ return $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
+ }
+ catch (PDOException $e)
+ {
+ return parent::version();
+ }
}
// --------------------------------------------------------------------