summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2011-10-06 02:41:38 +0200
committerTimothy Warren <tim@timshomepage.net>2011-10-06 02:41:38 +0200
commitf7a8d86dbc6805a4e52964bbea76738df75b5f35 (patch)
treee243d089d272b8eea3c548d0c4b9e2d435c5c390 /system/database/drivers
parent47663970e357c51ad16d1a1a3d3b52428c022505 (diff)
Changed all db constructors to newer syntax, made insert_id() function more convenient for postgres on pdo driver
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/odbc/odbc_driver.php4
-rw-r--r--system/database/drivers/pdo/pdo_driver.php20
2 files changed, 21 insertions, 3 deletions
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 08cd27b6c..bcd7937d9 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -48,9 +48,9 @@ class CI_DB_odbc_driver extends CI_DB {
var $_random_keyword;
- function CI_DB_odbc_driver($params)
+ function __construct($params)
{
- parent::CI_DB_driver($params);
+ parent::__construct($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 568819a08..1a84404bb 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -349,7 +349,25 @@ class CI_DB_pdo_driver extends CI_DB {
*/
function insert_id($name=NULL)
{
- return $this->conn_id->lastInsertId($name);
+ //Convenience method for postgres insertid
+ if(strpos($this->hostname, 'pgsql') !== FALSE)
+ {
+ $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
+ {
+ return $this->conn_id->lastInsertId($name);
+ }
}
// --------------------------------------------------------------------