vali 6 gadi atpakaļ
vecāks
revīzija
90f5620e77
1 mainītis faili ar 9 papildinājumiem un 5 dzēšanām
  1. 9 5
      datainf/logic/HttpServerRedisToSql.php

+ 9 - 5
datainf/logic/HttpServerRedisToSql.php

@@ -71,8 +71,7 @@ class HttpServerRedisToSql
     {
         $redisconfig = $this->redisonfig;
         go(function () use ($redisconfig) {
-            $rand = mt_rand(10000, 99999);
-            echo "单个线程开始时间:$rand " . microtime(true) . "\n";
+            $begint = microtime(true);
             $redis = new Swoole\Coroutine\Redis();
             $ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
             if (!$ret) {
@@ -109,11 +108,16 @@ class HttpServerRedisToSql
             if (!empty($batchsql)) {
                 $pdo = DB::getPdo();
                 $sqlstr = implode(";", $batchsql);
-                $pdo->exec($sqlstr);
+                $erowcount = $pdo->exec($sqlstr);
+                if (!$erowcount) {
+                    echo "\n发生错误:" . $pdo->errorCode() . ' ---- ' . $pdo->errorInfo() . "\n";
+                    echo "错误sql: " . $sqlstr . "\n\n";
+                } else {
+                    echo "成功运行:" . count($batchsql) . " 条!\n";
+                }
             }
             $redis->close();
-
-            echo "单个线程结束时间:$rand " . microtime(true) . "\n";
+            echo "总请求数" . $this->httpserver->account->get() . "  单个线程消耗时间: " . (microtime(true) - $begint) . " s \n";
 
             return;
         });