]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
fix record insertion
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 3 Aug 2013 07:48:59 +0000 (10:48 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 3 Aug 2013 07:48:59 +0000 (10:48 +0300)
ipf/orm/connection.php
ipf/orm/connection/unitofwork.php

index e1756521e88f97c99956261c4e6dda8c95f7e086..19317611c41c344448a793ba5ca13530c90307c0 100644 (file)
@@ -702,7 +702,7 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
         return $this->getAttribute(IPF_ORM::ATTR_QUERY_CACHE);
     }
 
-    public function lastInsertId($table = null, $field = null)
+    public function lastInsertId()
     {
         return $this->getDbh()->lastInsertId();
     }
index 07fa2600be317977a123607ea7bffe78d284c497..301b5d7c6d5f4b5a1f3a8be2dc3a5240e175e0bd 100644 (file)
@@ -399,17 +399,11 @@ class IPF_ORM_Connection_UnitOfWork extends IPF_ORM_Connection_Module
 
         $this->conn->insert($table, $fields);
 
-        if (empty($seq) && count($identifier) == 1 && $identifier[0] == $table->getIdentifier() &&
-            $table->getIdentifierType() != IPF_ORM::IDENTIFIER_NATURAL) {
-            if (strtolower($this->conn->getDriverName()) == 'Pgsql') {
-                $seq = $table->getTableName() . '_' . $identifier[0];
-            }
-
-            $id = $this->conn->lastInsertId($seq);
-
-            if ( ! $id) {
+        if (count($identifier) == 1 && $table->getIdentifierType() !== IPF_ORM::IDENTIFIER_NATURAL) {
+            $id = $this->conn->lastInsertId();
+            if (!$id)
                 throw new IPF_ORM_Exception("Couldn't get last insert identifier.");
-            }
+
             $record->assignIdentifier($id);
         } else {
             $record->assignIdentifier(true);