Commit b6ebd602 authored by bcosca's avatar bcosca
Browse files

Bug fix: PostgreSQL last insert ID (Issue #410)

parent a7e977c1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ class Mapper extends \DB\Cursor {
		//! Database engine
		$engine,
		//! SQL table
		$source,
		//! SQL table (quoted)
		$table,
		//! Last insert ID
		$_id,
@@ -332,7 +334,7 @@ class Mapper extends \DB\Cursor {
			);
		$seq=NULL;
		if ($this->engine=='pgsql')
			$seq=$this->table.'_'.end($pkeys).'_seq';
			$seq=$this->source.'_'.end($pkeys).'_seq';
		$this->_id=$this->db->lastinsertid($seq);
		if (!$inc) {
			$ctr=0;
@@ -486,6 +488,7 @@ class Mapper extends \DB\Cursor {
	function __construct(\DB\SQL $db,$table,$ttl=60) {
		$this->db=$db;
		$this->engine=$db->driver();
		$this->source=$table;
		$this->table=$this->db->quotekey($table);
		$this->fields=$db->schema($table,$ttl);
		$this->reset();