Browse Source

DbConnection insert return lastInsertId

walkor 10 năm trước cách đây
mục cha
commit
e8ad0a1424
2 tập tin đã thay đổi với 10 bổ sung4 xóa
  1. 7 1
      GatewayWorker/Lib/DbConnection.php
  2. 3 3
      GatewayWorker/Lib/Gateway.php

+ 7 - 1
GatewayWorker/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;
         }
@@ -1778,3 +1783,4 @@ class DbConnection
         return $this->lastSql;
     }
 }
+

+ 3 - 3
GatewayWorker/Lib/Gateway.php

@@ -118,15 +118,15 @@ class Gateway
                $client_array[$client_id] = $client;
            }
        }
-       // 超时2
-       $time_out = 2;
+       // 超时1
+       $time_out = 1;
        $time_start = microtime(true);
        // 批量接收请求
        while(count($client_array) > 0)
        {
            $write = $except = array();
            $read = $client_array;
-           if(@stream_select($read, $write, $except, 1))
+           if(@stream_select($read, $write, $except, $time_out))
            {
                foreach($read as $client)
                {