Răsfoiți Sursa

Merge pull request #16 from coco543/master

实现insert之后返回主键AI的ID
walkor 10 ani în urmă
părinte
comite
67c0f6bd22
1 a modificat fișierele cu 6 adăugiri și 1 ștergeri
  1. 6 1
      applications/Demo/Lib/DbConnection.php

+ 6 - 1
applications/Demo/Lib/DbConnection.php

@@ -1672,9 +1672,14 @@ class DbConnection
         if ($statement === 'select' || $statement === 'show') {
             return $this->sQuery->fetchAll($fetchmode);
         }
-        elseif ( $statement === 'insert' ||  $statement === 'update' || $statement === 'delete' ) {
+        elseif ( $statement === 'update' || $statement === 'delete' ) {
             return $this->sQuery->rowCount();
         }
+        elseif( $statement === 'insert' ){
+            if( $this->sQuery->rowCount() > 0 ){
+                return $this->lastInsertId();
+            }
+        }
         else {
             return NULL;
         }