Browse Source

Fix imi (#7410)

* Fix

* Fix

* Fix

* Fix
Yurun 3 years ago
parent
commit
018bef1245

+ 4 - 11
frameworks/PHP/imi/ApiServer/Controller/PgController.php

@@ -191,17 +191,10 @@ class PgController extends HttpController
             $values[] = $row['randomNumber'] = \mt_rand(1, 10000);
             $list[] = $row;
         }
-        $db->beginTransaction();
-        try {
-            $stmtUpdate->execute([
-                ...$values,
-                ...$keys
-            ]);
-            $db->commit();
-        } catch(\Throwable $th) {
-            $db->rollBack();
-            throw $th;
-        }
+        $stmtUpdate->execute([
+            ...$values,
+            ...$keys
+        ]);
 
         return $list;
     }

+ 3 - 0
frameworks/PHP/imi/Main.php

@@ -14,7 +14,10 @@ class Main extends AppBaseMain
         if(extension_loaded('swoole'))
         {
             \Co::set([
+                'socket_timeout'         => 30,
                 'socket_connect_timeout' => 5,
+                'socket_read_timeout'    => 30,
+                'socket_write_timeout'   => 30,
             ]);
         }
     }

+ 12 - 12
frameworks/PHP/imi/config/config.php

@@ -61,18 +61,20 @@ return [
         'defaultPool'   => $isMysql ? 'mysql' : 'pgsql', // 默认连接池
         'connections'   => [
             'mysql' => [
-                'host'        => $host,
-                'username'    => $username,
-                'password'    => $password,
-                'database'    => 'hello_world',
-                'dbClass'     => \Imi\Db\Mysql\Drivers\Mysqli\Driver::class,
+                'host'                        => $host,
+                'username'                    => $username,
+                'password'                    => $password,
+                'database'                    => 'hello_world',
+                'dbClass'                     => \Imi\Db\Mysql\Drivers\Mysqli\Driver::class,
+                'checkStateWhenGetResource'   => false,
             ],
             'pgsql' => [
-                'host'        => $host,
-                'username'    => $username,
-                'password'    => $password,
-                'database'    => 'hello_world',
-                'dbClass'     => \Imi\Pgsql\Db\Drivers\PdoPgsql\Driver::class,
+                'host'                        => $host,
+                'username'                    => $username,
+                'password'                    => $password,
+                'database'                    => 'hello_world',
+                'dbClass'                     => \Imi\Pgsql\Db\Drivers\PdoPgsql\Driver::class,
+                'checkStateWhenGetResource'   => false,
             ],
         ],
     ],
@@ -89,7 +91,6 @@ return [
                     'minResources' => $isMysql ? 16 : 0,
                     'gcInterval'   => 0,
                     'checkStateWhenGetResource' =>  false,
-                    'requestResourceCheckInterval' => 0,
                 ],
             ],
             // resource也可以定义多个连接
@@ -110,7 +111,6 @@ return [
                     // 池子中最少资源数
                     'minResources' => $isMysql ? 0 : 16,
                     'checkStateWhenGetResource' =>  false,
-                    'requestResourceCheckInterval' => 0,
                 ],
             ],
             // resource也可以定义多个连接