summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorRogerio Prado de Jesus <rogeriopradoj@gmail.com>2012-05-19 18:38:26 +0200
committerRogerio Prado de Jesus <rogeriopradoj@gmail.com>2012-05-19 18:38:26 +0200
commit9fa8d404790833a098a8bbd855f1452897d6ff88 (patch)
tree3cecc7877bf63e781e143490e1676d4921c7abbf /system/database/drivers
parentfbd31c8d98bd7e5eac5c8e8c2f102b05350db93e (diff)
Fix a issue with affect_rows in CI_DB_pdo_driver::_execute()
In case of SELECT queries PDOStatement::rowCount doesn't work as expected. This commit makes affect_rows be initialized properly. Signed-off-by: Rogerio Prado de Jesus <rogeriopradoj@gmail.com>
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/pdo/pdo_driver.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index c38b79c5a..952016848 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -189,11 +189,20 @@ class CI_DB_pdo_driver extends CI_DB {
function _execute($sql)
{
$sql = $this->_prep_query($sql);
- $result_id = $this->conn_id->query($sql);
+ $result_id = $this->conn_id->prepare($sql);
+ $result_id->execute();
if (is_object($result_id))
{
- $this->affect_rows = $result_id->rowCount();
+ if (is_numeric(stripos($sql, 'SELECT')))
+ {
+ $this->affect_rows = count($result_id->fetchAll());
+ $result_id->execute();
+ }
+ else
+ {
+ $this->affect_rows = $result_id->rowCount();
+ }
}
else
{