From 8ee01ce3b28500adbc365c90eb2d06bef1a13dc3 Mon Sep 17 00:00:00 2001 From: zYne Date: Mon, 11 Jun 2007 23:37:24 +0000 Subject: [PATCH] --- lib/Doctrine/Connection.php | 16 ++++++++++++++++ lib/Doctrine/Formatter.php | 2 ++ lib/Doctrine/Sequence/Pgsql.php | 3 +++ 3 files changed, 21 insertions(+) diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index 006392845..a77e2da48 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -902,6 +902,22 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun { return $this->transaction->getTransactionLevel(); } + /** + * lastInsertId + * + * Returns the ID of the last inserted row, or the last value from a sequence object, + * depending on the underlying driver. + * + * Note: This method may not return a meaningful or consistent result across different drivers, + * because the underlying database may not even support the notion of auto-increment fields or sequences. + * + * @param string $table name of the table into which a new row was inserted + * @param string $field name of the field into which a new row was inserted + */ + public function lastInsertId($table = null, $field = null) + { + return $this->sequence->lastInsertId($table, $field); + } /** * beginTransaction * Start a transaction or set a savepoint. diff --git a/lib/Doctrine/Formatter.php b/lib/Doctrine/Formatter.php index a0947d370..54d01d3b6 100644 --- a/lib/Doctrine/Formatter.php +++ b/lib/Doctrine/Formatter.php @@ -158,6 +158,8 @@ class Doctrine_Formatter extends Doctrine_Connection_Module case 'gzip': case 'blob': case 'clob': + $this->conn->connect(); + return $this->conn->getDbh()->quote($input); } } diff --git a/lib/Doctrine/Sequence/Pgsql.php b/lib/Doctrine/Sequence/Pgsql.php index 56c2a49d3..cd222b051 100644 --- a/lib/Doctrine/Sequence/Pgsql.php +++ b/lib/Doctrine/Sequence/Pgsql.php @@ -61,11 +61,14 @@ class Doctrine_Sequence_Pgsql extends Doctrine_Sequence return $result; } /** + * lastInsertId + * * Returns the autoincrement ID if supported or $id or fetches the current * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field) * * @param string name of the table into which a new row was inserted * @param string name of the field into which a new row was inserted + * @return integer the autoincremented id */ public function lastInsertId($table = null, $field = null) {