From 9016a7c0dd88ed6049e25874918ddf7a696b4767 Mon Sep 17 00:00:00 2001 From: Alexander Pankratov Date: Sun, 17 May 2020 00:38:30 +0300 Subject: [PATCH] Allow dots in mysql table names --- src/danog/MadelineProto/Db/MysqlArray.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/danog/MadelineProto/Db/MysqlArray.php b/src/danog/MadelineProto/Db/MysqlArray.php index 021c470d..565bc080 100644 --- a/src/danog/MadelineProto/Db/MysqlArray.php +++ b/src/danog/MadelineProto/Db/MysqlArray.php @@ -114,7 +114,7 @@ class MysqlArray implements DbArray } $row = yield $this->request( - "SELECT `value` FROM {$this->table} WHERE `key` = :index LIMIT 1", + "SELECT `value` FROM `{$this->table}` WHERE `key` = :index LIMIT 1", ['index' => $offset] ); @@ -192,7 +192,7 @@ class MysqlArray implements DbArray */ public function getArrayCopy(): array { - $rows = $this->syncRequest("SELECT `key`, `value` FROM {$this->table}"); + $rows = $this->syncRequest("SELECT `key`, `value` FROM `{$this->table}`"); $result = []; foreach ($rows as $row) { $result[$row['key']] = $this->getValue($row); @@ -204,7 +204,7 @@ class MysqlArray implements DbArray public function getIterator(): Producer { return new Producer(function (callable $emit) { - $request = yield $this->db->execute("SELECT `key`, `value` FROM {$this->table}"); + $request = yield $this->db->execute("SELECT `key`, `value` FROM `{$this->table}`"); while (yield $request->advance()) { $row = $request->getCurrent(); @@ -225,7 +225,7 @@ class MysqlArray implements DbArray public function count(): Promise { return call(function(){ - $row = yield $this->request("SELECT count(`key`) as `count` FROM {$this->table}"); + $row = yield $this->request("SELECT count(`key`) as `count` FROM `{$this->table}`"); return $row[0]['count'] ?? 0; }); } @@ -279,11 +279,11 @@ class MysqlArray implements DbArray private function renameTable(string $from, string $to) { yield $this->request(" - ALTER TABLE {$from} RENAME TO {$to}; + ALTER TABLE `{$from}` RENAME TO `{$to}`; "); yield $this->request(" - DROP TABLE IF EXISTS {$from}; + DROP TABLE IF EXISTS `{$from}`; "); }