Browse Source

Update DB\Mysql

Visman 3 years ago
parent
commit
04f5906281
1 changed files with 4 additions and 4 deletions
  1. 4 4
      app/Core/DB/Mysql.php

+ 4 - 4
app/Core/DB/Mysql.php

@@ -175,11 +175,10 @@ class Mysql
     public function indexExists(string $table, string $index, bool $noPrefix = false): bool
     public function indexExists(string $table, string $index, bool $noPrefix = false): bool
     {
     {
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
-        $index = 'PRIMARY' == $index ? $index : $table . '_' . $index;
 
 
         $vars = [
         $vars = [
             ':tname' => $table,
             ':tname' => $table,
-            ':index' => $index,
+            ':index' => 'PRIMARY' == $index ? $index : $table . '_' . $index,
         ];
         ];
         $query = 'SELECT 1
         $query = 'SELECT 1
             FROM INFORMATION_SCHEMA.STATISTICS
             FROM INFORMATION_SCHEMA.STATISTICS
@@ -567,11 +566,12 @@ class Mysql
     public function getMap(): array
     public function getMap(): array
     {
     {
         $vars = [
         $vars = [
-            str_replace('_', '\\_', $this->dbPrefix) . '%',
+            ':tname' => str_replace('_', '\\_', $this->dbPrefix) . '%',
         ];
         ];
         $query = 'SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
         $query = 'SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
             FROM INFORMATION_SCHEMA.COLUMNS
             FROM INFORMATION_SCHEMA.COLUMNS
-            WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME LIKE ?s';
+            WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME LIKE ?s:tname
+            ORDER BY TABLE_NAME';
 
 
         $stmt   = $this->db->query($query, $vars);
         $stmt   = $this->db->query($query, $vars);
         $result = [];
         $result = [];