summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-01 18:11:39 +0100
committerAndrey Andreev <narf@bofh.bg>2012-03-01 18:11:39 +0100
commita39d699f90feb359ab994b3d77d71006060afecc (patch)
tree9a89292e86ca41dbbe5bcb587c498970a9df5d6c /system
parented7408282e9fded97ade222f98b43623a0f17d22 (diff)
Fix a bug in PDO's insert_id() (PostgreSQL-specific)
Diffstat (limited to 'system')
-rw-r--r--system/database/drivers/pdo/pdo_driver.php32
1 files changed, 9 insertions, 23 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 44e93a042..dd803aba1 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -509,33 +509,19 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Insert ID
- *
- * @access public
- * @return integer
+ *
+ * @return int
*/
- function insert_id($name=NULL)
+ public function insert_id($name = NULL)
{
- if ($this->pdodriver == 'pgsql')
- {
- //Convenience method for postgres insertid
- $v = $this->_version();
-
- $table = func_num_args() > 0 ? func_get_arg(0) : NULL;
-
- if ($table == NULL && $v >= '8.1')
- {
- $sql='SELECT LASTVAL() as ins_id';
- }
-
- $query = $this->query($sql);
- $row = $query->row();
-
- return $row->ins_id;
- }
- else
+ if ($this->pdodriver === 'pgsql' && $name === NULL && $this->_version() >= '8.1')
{
- return $this->conn_id->lastInsertId($name);
+ $query = $this->query('SELECT LASTVAL() AS ins_id');
+ $query = $query->row();
+ return $query->ins_id;
}
+
+ return $this->conn_id->lastInsertId($name);
}
// --------------------------------------------------------------------