@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - private $types = [ //! arrays |
|
| 24 | + private $types = [//! arrays |
|
| 25 | 25 | 'Numbers' => ["integer" => 0, "real" => 0, "numeric" => 0], |
| 26 | 26 | 'Strings' => ["text" => 0], |
| 27 | 27 | 'Binary' => ["blob" => 0], |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | private $editFunctions = [[ |
| 65 | 65 | // "text" => "date('now')/time('now')/datetime('now')", |
| 66 | - ],[ |
|
| 66 | + ], [ |
|
| 67 | 67 | "integer|real|numeric" => "+/-", |
| 68 | 68 | // "text" => "date/time/datetime", |
| 69 | 69 | "text" => "||", |
@@ -85,11 +85,9 @@ |
||
| 85 | 85 | $connection = null; |
| 86 | 86 | if (class_exists("SQLite3")) { |
| 87 | 87 | $connection = new Db\Sqlite\Connection($this, $this->util, $this->trans, 'SQLite3'); |
| 88 | - } |
|
| 89 | - elseif (extension_loaded("pdo_sqlite")) { |
|
| 88 | + } elseif (extension_loaded("pdo_sqlite")) { |
|
| 90 | 89 | $connection = new Db\Pdo\Connection($this, $this->util, $this->trans, 'PDO_SQLite'); |
| 91 | - } |
|
| 92 | - else { |
|
| 90 | + } else { |
|
| 93 | 91 | throw new AuthException($this->trans->lang('No package installed to open a Sqlite database.')); |
| 94 | 92 | } |
| 95 | 93 | |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | return preg_match('~^INTO~', $query) || |
| 32 | 32 | $this->connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')") ? |
| 33 | - $this->limit($query, $where, 1, 0, $separator) : |
|
| 34 | - //! use primary key in tables with WITHOUT rowid |
|
| 33 | + $this->limit($query, $where, 1, 0, $separator) : //! use primary key in tables with WITHOUT rowid |
|
| 35 | 34 | " $query WHERE rowid = (SELECT rowid FROM " . $this->table($table) . $where . $separator . "LIMIT 1)"; |
| 36 | 35 | } |
| 37 | 36 | |
@@ -54,7 +53,7 @@ discard block |
||
| 54 | 53 | if ($name == '') { |
| 55 | 54 | continue; |
| 56 | 55 | } |
| 57 | - $columns = implode(", ", array_map(function ($key) { |
|
| 56 | + $columns = implode(", ", array_map(function($key) { |
|
| 58 | 57 | return $this->escapeId($key); |
| 59 | 58 | }, $index->columns)); |
| 60 | 59 | $query .= ";\n\n" . $this->sqlForCreateIndex($table, $index->type, $name, "($columns)"); |
@@ -27,10 +27,10 @@ |
||
| 27 | 27 | $directory = rtrim($this->driver->options('directory'), '/\\'); |
| 28 | 28 | $iterator = new DirectoryIterator($directory); |
| 29 | 29 | // Iterate on dir content |
| 30 | - foreach($iterator as $file) |
|
| 30 | + foreach ($iterator as $file) |
|
| 31 | 31 | { |
| 32 | 32 | // Skip everything except Sqlite files |
| 33 | - if(!$file->isFile() || !$this->validateName($filename = $file->getFilename())) |
|
| 33 | + if (!$file->isFile() || !$this->validateName($filename = $file->getFilename())) |
|
| 34 | 34 | { |
| 35 | 35 | continue; |
| 36 | 36 | } |
@@ -56,8 +56,7 @@ |
||
| 56 | 56 | public function quote(string $string) |
| 57 | 57 | { |
| 58 | 58 | return ($this->util->isUtf8($string) ? |
| 59 | - "'" . $this->client->escapeString($string) . "'" : |
|
| 60 | - "x'" . reset(unpack('H*', $string)) . "'"); |
|
| 59 | + "'" . $this->client->escapeString($string) . "'" : "x'" . reset(unpack('H*', $string)) . "'"); |
|
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | /** |
@@ -84,8 +84,7 @@ discard block |
||
| 84 | 84 | "text" : (preg_match('~blob~i', $type) ? "blob" : (preg_match('~real|floa|doub~i', $type) ? |
| 85 | 85 | "real" : "numeric")))); |
| 86 | 86 | $field->fullType = $type; |
| 87 | - $field->default = (preg_match("~'(.*)'~", $default, $match) ? str_replace("''", "'", $match[1]) : |
|
| 88 | - ($default == "NULL" ? null : $default)); |
|
| 87 | + $field->default = (preg_match("~'(.*)'~", $default, $match) ? str_replace("''", "'", $match[1]) : ($default == "NULL" ? null : $default)); |
|
| 89 | 88 | $field->null = !$row["notnull"]; |
| 90 | 89 | $field->privileges = ["select" => 1, "insert" => 1, "update" => 1]; |
| 91 | 90 | $field->primary = $row["pk"]; |
@@ -327,7 +326,7 @@ discard block |
||
| 327 | 326 | if ($originals && !$this->driver->execute("INSERT INTO " . $this->driver->table($tempName) . |
| 328 | 327 | " (" . implode(", ", $originals) . ") SELECT " . implode( |
| 329 | 328 | ", ", |
| 330 | - array_map(function ($key) { |
|
| 329 | + array_map(function($key) { |
|
| 331 | 330 | return $this->driver->escapeId($key); |
| 332 | 331 | }, array_keys($originals)) |
| 333 | 332 | ) . " FROM " . $this->driver->table($table))) { |
@@ -339,8 +338,7 @@ discard block |
||
| 339 | 338 | $triggers[] = "CREATE TRIGGER " . $this->driver->escapeId($trigger_name) . " " . |
| 340 | 339 | implode(" ", $timing_event) . " ON " . $this->driver->table($name) . "\n$trigger[Statement]"; |
| 341 | 340 | } |
| 342 | - $autoIncrement = $autoIncrement ? 0 : |
|
| 343 | - $this->connection->result("SELECT seq FROM sqlite_sequence WHERE name = " . |
|
| 341 | + $autoIncrement = $autoIncrement ? 0 : $this->connection->result("SELECT seq FROM sqlite_sequence WHERE name = " . |
|
| 344 | 342 | $this->driver->quote($table)); // if $autoIncrement is set then it will be updated later |
| 345 | 343 | // drop before creating indexes and triggers to allow using old names |
| 346 | 344 | if (!$this->driver->execute("DROP TABLE " . $this->driver->table($table)) || |
@@ -374,8 +372,7 @@ discard block |
||
| 374 | 372 | } |
| 375 | 373 | foreach (array_reverse($alter) as $val) { |
| 376 | 374 | if (!$this->driver->execute($val[2] == "DROP" ? |
| 377 | - "DROP INDEX " . $this->driver->escapeId($val[1]) : |
|
| 378 | - $this->driver->sqlForCreateIndex($table, $val[0], $val[1], "(" . implode(", ", $val[2]) . ")") |
|
| 375 | + "DROP INDEX " . $this->driver->escapeId($val[1]) : $this->driver->sqlForCreateIndex($table, $val[0], $val[1], "(" . implode(", ", $val[2]) . ")") |
|
| 379 | 376 | )) { |
| 380 | 377 | return false; |
| 381 | 378 | } |