@@ -71,7 +71,7 @@ |
||
| 71 | 71 | "char" => "md5/sha1/password/encrypt/uuid", |
| 72 | 72 | "binary" => "md5/sha1", |
| 73 | 73 | "date|time" => "now", |
| 74 | - ],[ |
|
| 74 | + ], [ |
|
| 75 | 75 | // $this->numberRegex() => "+/-", |
| 76 | 76 | "date" => "+ interval/- interval", |
| 77 | 77 | "time" => "addtime/subtime", |
@@ -94,11 +94,9 @@ |
||
| 94 | 94 | { |
| 95 | 95 | if (extension_loaded("mysqli")) { |
| 96 | 96 | $connection = new Db\MySqli\Connection($this, $this->util, $this->trans, 'MySQLi'); |
| 97 | - } |
|
| 98 | - elseif (extension_loaded("pdo_mysql")) { |
|
| 97 | + } elseif (extension_loaded("pdo_mysql")) { |
|
| 99 | 98 | $connection = new Db\Pdo\Connection($this, $this->util, $this->trans, 'PDO_MySQL'); |
| 100 | - } |
|
| 101 | - else { |
|
| 99 | + } else { |
|
| 102 | 100 | throw new AuthException($this->trans->lang('No package installed to connect to a MySQL server.')); |
| 103 | 101 | } |
| 104 | 102 | |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | class Connection extends AbstractConnection |
| 13 | 13 | { |
| 14 | 14 | /** |
| 15 | - * @inheritDoc |
|
| 16 | - */ |
|
| 15 | + * @inheritDoc |
|
| 16 | + */ |
|
| 17 | 17 | public function open(string $database, string $schema = '') |
| 18 | 18 | { |
| 19 | 19 | $server = $this->driver->options('server'); |
@@ -15,8 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | // !!! Caching and slow query handling are temporarily disabled !!! |
| 17 | 17 | $query = $this->driver->minVersion(5) ? |
| 18 | - "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA ORDER BY SCHEMA_NAME" : |
|
| 19 | - "SHOW DATABASES"; |
|
| 18 | + "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA ORDER BY SCHEMA_NAME" : "SHOW DATABASES"; |
|
| 20 | 19 | return $this->driver->values($query); |
| 21 | 20 | |
| 22 | 21 | // SHOW DATABASES can take a very long time so it is cached |
@@ -121,7 +120,7 @@ discard block |
||
| 121 | 120 | */ |
| 122 | 121 | public function dropDatabases(array $databases) |
| 123 | 122 | { |
| 124 | - return $this->driver->applyQueries("DROP DATABASE", $databases, function ($database) { |
|
| 123 | + return $this->driver->applyQueries("DROP DATABASE", $databases, function($database) { |
|
| 125 | 124 | return $this->driver->escapeId($database); |
| 126 | 125 | }); |
| 127 | 126 | } |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | $query = ($fast && $this->driver->minVersion(5)) ? |
| 26 | 26 | "SELECT TABLE_NAME AS Name, ENGINE AS Engine, TABLE_COMMENT AS Comment " . |
| 27 | 27 | "FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() " . |
| 28 | - ($table != "" ? "AND TABLE_NAME = " . $this->driver->quote($table) : "ORDER BY Name") : |
|
| 29 | - "SHOW TABLE STATUS" . ($table != "" ? " LIKE " . $this->driver->quote(addcslashes($table, "%_\\")) : ""); |
|
| 28 | + ($table != "" ? "AND TABLE_NAME = " . $this->driver->quote($table) : "ORDER BY Name") : "SHOW TABLE STATUS" . ($table != "" ? " LIKE " . $this->driver->quote(addcslashes($table, "%_\\")) : ""); |
|
| 30 | 29 | return $this->driver->rows($query); |
| 31 | 30 | } |
| 32 | 31 | |
@@ -181,8 +180,7 @@ discard block |
||
| 181 | 180 | $index = new IndexEntity(); |
| 182 | 181 | |
| 183 | 182 | $name = $row["Key_name"]; |
| 184 | - $index->type = ($name == "PRIMARY" ? "PRIMARY" : |
|
| 185 | - ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? |
|
| 183 | + $index->type = ($name == "PRIMARY" ? "PRIMARY" : ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? |
|
| 186 | 184 | ($row["Index_type"] == "SPATIAL" ? "SPATIAL" : "INDEX") : "UNIQUE"))); |
| 187 | 185 | $index->columns[] = $row["Column_name"]; |
| 188 | 186 | $index->lengths[] = ($row["Index_type"] == "SPATIAL" ? null : $row["Sub_part"]); |
@@ -222,10 +220,10 @@ discard block |
||
| 222 | 220 | |
| 223 | 221 | $foreignKey->database = $this->driver->unescapeId($match4 != "" ? $match3 : $match4); |
| 224 | 222 | $foreignKey->table = $this->driver->unescapeId($match4 != "" ? $match4 : $match3); |
| 225 | - $foreignKey->source = array_map(function ($idf) { |
|
| 223 | + $foreignKey->source = array_map(function($idf) { |
|
| 226 | 224 | return $this->driver->unescapeId($idf); |
| 227 | 225 | }, $source[0]); |
| 228 | - $foreignKey->target = array_map(function ($idf) { |
|
| 226 | + $foreignKey->target = array_map(function($idf) { |
|
| 229 | 227 | return $this->driver->unescapeId($idf); |
| 230 | 228 | }, $target[0]); |
| 231 | 229 | $foreignKey->onDelete = $matchCount > 6 ? $match[6] : "RESTRICT"; |
@@ -18,8 +18,7 @@ discard block |
||
| 18 | 18 | foreach ($fields as $field) { |
| 19 | 19 | $alter[] = ($field[1] ? ($table != '' ? ($field[0] != '' ? 'CHANGE ' . |
| 20 | 20 | $this->driver->escapeId($field[0]) : 'ADD') : ' ') . ' ' . |
| 21 | - implode($field[1]) . ($table != '' ? $field[2] : '') : |
|
| 22 | - 'DROP ' . $this->driver->escapeId($field[0]) |
|
| 21 | + implode($field[1]) . ($table != '' ? $field[2] : '') : 'DROP ' . $this->driver->escapeId($field[0]) |
|
| 23 | 22 | ); |
| 24 | 23 | } |
| 25 | 24 | $alter = array_merge($alter, $foreign); |
@@ -69,8 +68,7 @@ discard block |
||
| 69 | 68 | public function tables() |
| 70 | 69 | { |
| 71 | 70 | return $this->driver->keyValues($this->driver->minVersion(5) ? |
| 72 | - 'SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME' : |
|
| 73 | - 'SHOW TABLES'); |
|
| 71 | + 'SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME' : 'SHOW TABLES'); |
|
| 74 | 72 | } |
| 75 | 73 | |
| 76 | 74 | /** |
@@ -90,7 +88,7 @@ discard block |
||
| 90 | 88 | */ |
| 91 | 89 | public function dropViews(array $views) |
| 92 | 90 | { |
| 93 | - $this->driver->execute('DROP VIEW ' . implode(', ', array_map(function ($view) { |
|
| 91 | + $this->driver->execute('DROP VIEW ' . implode(', ', array_map(function($view) { |
|
| 94 | 92 | return $this->driver->table($view); |
| 95 | 93 | }, $views))); |
| 96 | 94 | return true; |
@@ -101,7 +99,7 @@ discard block |
||
| 101 | 99 | */ |
| 102 | 100 | public function dropTables(array $tables) |
| 103 | 101 | { |
| 104 | - $this->driver->execute('DROP TABLE ' . implode(', ', array_map(function ($table) { |
|
| 102 | + $this->driver->execute('DROP TABLE ' . implode(', ', array_map(function($table) { |
|
| 105 | 103 | return $this->driver->table($table); |
| 106 | 104 | }, $tables))); |
| 107 | 105 | return true; |
@@ -161,16 +159,14 @@ discard block |
||
| 161 | 159 | foreach ($this->driver->rows('SHOW TRIGGERS LIKE ' . $this->driver->quote(addcslashes($table, "%_\\"))) as $row) { |
| 162 | 160 | $trigger = $row['Trigger']; |
| 163 | 161 | if (!$this->driver->execute('CREATE TRIGGER ' . |
| 164 | - ($target == $this->driver->database() ? $this->driver->escapeId("copy_$trigger") : |
|
| 165 | - $this->driver->escapeId($target) . '.' . $this->driver->escapeId($trigger)) . |
|
| 162 | + ($target == $this->driver->database() ? $this->driver->escapeId("copy_$trigger") : $this->driver->escapeId($target) . '.' . $this->driver->escapeId($trigger)) . |
|
| 166 | 163 | " $row[Timing] $row[Event] ON $name FOR EACH ROW\n$row[Statement];")) { |
| 167 | 164 | return false; |
| 168 | 165 | } |
| 169 | 166 | } |
| 170 | 167 | } |
| 171 | 168 | foreach ($views as $table) { |
| 172 | - $name = ($target == $this->driver->database() ? $this->driver->table("copy_$table") : |
|
| 173 | - $this->driver->escapeId($target) . '.' . $this->driver->table($table)); |
|
| 169 | + $name = ($target == $this->driver->database() ? $this->driver->table("copy_$table") : $this->driver->escapeId($target) . '.' . $this->driver->table($table)); |
|
| 174 | 170 | $view = $this->driver->view($table); |
| 175 | 171 | if (($overwrite && !$this->driver->execute("DROP VIEW IF EXISTS $name")) |
| 176 | 172 | || !$this->driver->execute("CREATE VIEW $name AS $view[select]")) { //! USE to avoid db.table |