Prechádzať zdrojové kódy

fixed: TableExists()判断逻辑.

王刚 3 rokov pred
rodič
commit
78b943df7a

+ 4 - 1
Gameserver/Amfphp/test.php

@@ -8,8 +8,11 @@ include __DIR__ . '/main.php';
 
 echoLine("phpver: " . PHP_VERSION . PHP_EOL);
 echoLine("tsDay:" . totalDays());
-//SelfChecker::CheckAll();
+
+SelfChecker::CheckAll();
 //
 //set_time_limit(15);                                                           # 设置执行超时时间
 //
+
+
  

+ 5 - 4
Gameserver/Amfphp/util/SelfChecker.php

@@ -10,8 +10,8 @@ namespace loyalsoft;
 class SelfChecker {
 
     public static function CheckAll() {
-//        self:: checkkPHPVersion();
-//        self::checkModules();
+        self:: checkkPHPVersion();
+        self::checkModules();
         self::CheckDNS();
         self::CheckNetRead();
         self::CheckConfig();
@@ -25,6 +25,7 @@ class SelfChecker {
         $default = array(#                                                      # 必备基础模块
             "curl",
             "mbstring",
+            "mongodb",
             "openssl",
             "pdo_mysql",
             "sockets",
@@ -91,7 +92,7 @@ class SelfChecker {
         echoLine("Redis Write($key, 'Hello world!'):" . gMem()->set($key, "Hello world!"));
         echoLine("Redis Read($key): " . gMem()->get($key));
         echo("Profile Redis set/get: ");
-        RenderTime::Test(function ()use($key) {
+        RenderTime::Test(function ()use ($key) {
             gMem()->set($key, "Hello world!");
             gMem()->get($key);
         }, 100);
@@ -116,7 +117,7 @@ class SelfChecker {
         $row = daoInst()->insert("`$tableName`")->data(array('msg' => 'Hello world!'))->exec();
         echoLine("Insert into `$tableName` " . ($row == 1 ? "ok!" : "failed!"));
         echo("Profile Insert: ");
-        RenderTime::Test(function()use($tableName) {
+        RenderTime::Test(function ()use ($tableName) {
             daoInst()->insert("`$tableName`")->data(array('msg' => 'Hello world!'))->exec();
         }, 100);
         $sql = "Drop Table `$tableName`;";

+ 6 - 4
Gameserver/Amfphp/util/dao.php

@@ -978,16 +978,18 @@ class dao {
         $this->reset();
         $this->setMethod('select');
         $sql = "SELECT 1 FROM `$tableName` LIMIT 1";
+        $ret = false;
         try {
             if ($this->slaveDBH and $this->method == 'select') {
-                $ret = $this->slaveDBH->query($sql)->fetch();
+                $ret = $this->slaveDBH->query($sql)->fetchAll();
             } else {
-                $ret = $this->dbh->query($sql)->fetch();
+                $ret = $this->dbh->query($sql)->fetchAll();
             }
-        } catch (\Exception $exc) {
+        } catch (\Exception $exc) {                                             # 表不存在的时候直接进异常处理逻辑.
+            CLog::err($exc->getMessage());
             return false;
         }
-        // Result is either boolean FALSE (no table found) or PDOStatement Object (table found)
+        // Result is either boolean FALSE (no table found) or PDOStatement Object (table found) 
         return $ret !== FALSE;      # false代表表不存在
     }