Browse Source

A little loop optimization

Visman 3 years ago
parent
commit
1800381095
3 changed files with 6 additions and 3 deletions
  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);
         $stmt   = $this->db->query($query, $vars);
         $result = [];
         $result = [];
         $table  = null;
         $table  = null;
+        $prfLen = \strlen($this->dbPrefix);
 
 
         while ($row = $stmt->fetch()) {
         while ($row = $stmt->fetch()) {
             if ($table !== $row['TABLE_NAME']) {
             if ($table !== $row['TABLE_NAME']) {
                 $table                = $row['TABLE_NAME'];
                 $table                = $row['TABLE_NAME'];
-                $tableNoPref          = \substr($table, \strlen($this->dbPrefix));
+                $tableNoPref          = \substr($table, $prfLen);
                 $result[$tableNoPref] = [];
                 $result[$tableNoPref] = [];
             }
             }
 
 

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

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

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

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