瀏覽代碼

A little loop optimization

Visman 3 年之前
父節點
當前提交
1800381095
共有 3 個文件被更改,包括 6 次插入3 次删除
  1. 2 1
      app/Core/DB/Mysql.php
  2. 2 1
      app/Core/DB/Pgsql.php
  3. 2 1
      app/Core/DB/Sqlite.php

+ 2 - 1
app/Core/DB/Mysql.php

@@ -576,11 +576,12 @@ class Mysql
         $stmt   = $this->db->query($query, $vars);
         $result = [];
         $table  = null;
+        $prfLen = \strlen($this->dbPrefix);
 
         while ($row = $stmt->fetch()) {
             if ($table !== $row['TABLE_NAME']) {
                 $table                = $row['TABLE_NAME'];
-                $tableNoPref          = \substr($table, \strlen($this->dbPrefix));
+                $tableNoPref          = \substr($table, $prfLen);
                 $result[$tableNoPref] = [];
             }
 

+ 2 - 1
app/Core/DB/Pgsql.php

@@ -530,11 +530,12 @@ class Pgsql
         $stmt   = $this->db->query($query, $vars);
         $result = [];
         $table  = null;
+        $prfLen = \strlen($this->dbPrefix);
 
         while ($row = $stmt->fetch()) {
             if ($table !== $row['table_name']) {
                 $table                = $row['table_name'];
-                $tableNoPref          = \substr($table, \strlen($this->dbPrefix));
+                $tableNoPref          = \substr($table, $prfLen);
                 $result[$tableNoPref] = [];
             }
 

+ 2 - 1
app/Core/DB/Sqlite.php

@@ -479,11 +479,12 @@ class Sqlite
         $stmt   = $this->db->query($query, $vars);
         $result = [];
         $table  = null;
+        $prfLen = \strlen($this->dbPrefix);
 
         while ($row = $stmt->fetch()) {
             if ($table !== $row['table_name']) {
                 $table                = $row['table_name'];
-                $tableNoPref          = \substr($table, \strlen($this->dbPrefix));
+                $tableNoPref          = \substr($table, $prfLen);
                 $result[$tableNoPref] = [];
             }