From 4fa4cbfb51b0683a508d78c33aeb8bf5608f5efd Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sat, 28 Dec 2019 01:08:43 +0100 Subject: [PATCH 01/11] bump --- composer.json | 79 ++++++----- src/TestSuite/Fixture/ChecksumTestFixture.php | 130 +++++++++--------- 2 files changed, 110 insertions(+), 99 deletions(-) diff --git a/composer.json b/composer.json index 89d5ba0..7495eba 100644 --- a/composer.json +++ b/composer.json @@ -1,40 +1,47 @@ { - "name": "friendsofcake/fixturize", - "description": "CakePHP Fixture classes to help increase productivity or performance", - "type": "cakephp-plugin", - "keywords": [ - "cakephp", - "fixture", - "fixtures", - "unittest", - "phpunit", - "performance" - ], - "homepage": "https://github.com/FriendsOfCake/fixturize", - "license": "MIT", - "authors": [ - { - "name": "Christian Winther", - "role": "Author", - "homepage": "http://cakephp.nu/" + "name": "friendsofcake/fixturize", + "description": "CakePHP Fixture classes to help increase productivity or performance", + "type": "cakephp-plugin", + "keywords": [ + "cakephp", + "fixture", + "fixtures", + "unittest", + "phpunit", + "performance" + ], + "homepage": "https://github.com/FriendsOfCake/fixturize", + "license": "MIT", + "authors": [ + { + "name": "Christian Winther", + "role": "Author", + "homepage": "http://cakephp.nu/" + }, + { + "name": "José Lorenzo Rodríguez", + "role": "Contributor", + "homepage": "https://github.com/lorenzo" + } + ], + "autoload": { + "psr-4": { + "FriendsOfCake\\Fixturize\\": "src" + } }, - { - "name": "José Lorenzo Rodríguez", - "role": "Contributor", - "homepage": "https://github.com/lorenzo" - } - ], - "autoload": { - "psr-4": { - "FriendsOfCake\\Fixturize\\": "src" + "scripts": { + "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/", + "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/" + }, + "require": { + "cakephp/cakephp": "^4.0" + }, + "require-dev": { + "cakephp/cakephp-codesniffer": "^4.0" + }, + "support": { + "source": "https://github.com/FriendsOfCake/fixturize", + "issues": "https://github.com/FriendsOfCake/fixturize/issues", + "irc": "irc://irc.freenode.org/cakephp" } - }, - "require": { - "cakephp/cakephp": "^3.2" - }, - "support": { - "source": "https://github.com/FriendsOfCake/fixturize", - "issues": "https://github.com/FriendsOfCake/fixturize/issues", - "irc": "irc://irc.freenode.org/cakephp" - } } diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index c4e9378..7089fb2 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -1,9 +1,11 @@ _tableUnmodified($db)) { return true; } $result = parent::insert($db); - static::$_tableHashes[$this->_getTableKey()] = $this->_hash($db); + static::$tableHashes[$this->_getTableKey()] = $this->_hash($db); + return $result; } -/** - * Deletes all table information. - * - * This will only happen if the underlying table is modified in any way - * - * @param ConnectionInterface $db - * @return void - */ - public function truncate(ConnectionInterface $db) + /** + * Deletes all table information. + * + * This will only happen if the underlying table is modified in any way + * + * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance + * @return bool + */ + public function truncate(ConnectionInterface $db): bool { if ($this->_tableUnmodified($db)) { return true; @@ -60,50 +62,51 @@ public function truncate(ConnectionInterface $db) return parent::truncate($db); } -/** - * Drops the table from the test datasource - * - * @param ConnectionInterface $db - * @return void - */ - public function drop(ConnectionInterface $db) + /** + * Drops the table from the test datasource + * + * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance + * @return bool + */ + public function drop(ConnectionInterface $db): bool { - unset(static::$_tableHashes[$this->_getTableKey()]); + unset(static::$tableHashes[$this->_getTableKey()]); + return parent::drop($db); } -/** - * Test if a table is modified or not - * - * If there is no known hash, treat it as being modified - * - * In all other cases where the initial and current hash differs, assume - * the table has changed - * - * @param DboSource $db - * @return boolean - */ - protected function _tableUnmodified($db) + /** + * Test if a table is modified or not + * + * If there is no known hash, treat it as being modified + * + * In all other cases where the initial and current hash differs, assume + * the table has changed + * + * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance + * @return bool + */ + protected function _tableUnmodified(ConnectionInterface $db): bool { $tableKey = $this->_getTableKey(); - if (!array_key_exists($tableKey, static::$_tableHashes)) { + if (!array_key_exists($tableKey, static::$tableHashes)) { return false; } - if (static::$_tableHashes[$tableKey] === $this->_hash($db)) { + if (static::$tableHashes[$tableKey] === $this->_hash($db)) { return true; } return false; } -/** - * Get the table hash from MySQL for a specific table - * - * @param ConnectionInterface $db - * @return string - */ - protected function _hash(ConnectionInterface $db) + /** + * Get the table hash from MySQL for a specific table + * + * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance + * @return string + */ + protected function _hash(ConnectionInterface $db): string { $driver = $db->getDriver(); @@ -115,15 +118,16 @@ protected function _hash(ConnectionInterface $db) $sth = $db->execute("CHECKSUM TABLE " . $this->table . ';'); $result = $sth->fetch('assoc'); $checksum = $result['Checksum']; + return $checksum; } -/** - * Get the key for table hashes - * - * @return string key for specify connection and table - */ - protected function _getTableKey () + /** + * Get the key for table hashes + * + * @return string key for specify connection and table + */ + protected function _getTableKey(): string { return $this->connection() . '-' . $this->table; } From 9cf3d339be23f2f492b5b66505a41ec0e043a00a Mon Sep 17 00:00:00 2001 From: Matthias Wirtz <2990373+swiffer@users.noreply.github.com> Date: Sat, 28 Dec 2019 13:26:30 +0100 Subject: [PATCH 02/11] Update ChecksumTestFixture.php --- src/TestSuite/Fixture/ChecksumTestFixture.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index 7089fb2..3e9c118 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -22,7 +22,7 @@ class ChecksumTestFixture extends TestFixture * * @var array */ - public static $tableHashes = []; + protected static $_tableHashes = []; /** * Inserts records in the database @@ -40,7 +40,7 @@ public function insert(ConnectionInterface $db): bool } $result = parent::insert($db); - static::$tableHashes[$this->_getTableKey()] = $this->_hash($db); + static::$_tableHashes[$this->_getTableKey()] = $this->_hash($db); return $result; } @@ -70,7 +70,7 @@ public function truncate(ConnectionInterface $db): bool */ public function drop(ConnectionInterface $db): bool { - unset(static::$tableHashes[$this->_getTableKey()]); + unset(static::$_tableHashes[$this->_getTableKey()]); return parent::drop($db); } @@ -89,11 +89,11 @@ public function drop(ConnectionInterface $db): bool protected function _tableUnmodified(ConnectionInterface $db): bool { $tableKey = $this->_getTableKey(); - if (!array_key_exists($tableKey, static::$tableHashes)) { + if (!array_key_exists($tableKey, static::$_tableHashes)) { return false; } - if (static::$tableHashes[$tableKey] === $this->_hash($db)) { + if (static::$_tableHashes[$tableKey] === $this->_hash($db)) { return true; } From 503d622ebd83fcd9c588adb9a760132a3950772e Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sat, 28 Dec 2019 13:45:27 +0100 Subject: [PATCH 03/11] compatibility for Postgres --- src/TestSuite/Fixture/ChecksumTestFixture.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index 3e9c118..dc122b4 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -4,6 +4,7 @@ namespace FriendsOfCake\Fixturize\TestSuite\Fixture; use Cake\Database\Driver\Mysql; +use Cake\Database\Driver\Postgres; use Cake\Datasource\ConnectionInterface; use Cake\TestSuite\Fixture\TestFixture; @@ -110,16 +111,19 @@ protected function _hash(ConnectionInterface $db): string { $driver = $db->getDriver(); - if (!$driver instanceof Mysql) { - // Have no better idea right now to make it always regenerate the tables - return microtime(); + if ($driver instanceof Mysql) { + $sth = $db->execute("CHECKSUM TABLE " . $this->table . ';'); + return $sth->fetchColumn(0); + } elseif ($driver instanceof Postgres) { + $primary_key = $this->getTableSchema()->getPrimaryKey(); + if (!empty($primary_key)) { + $sth = $db->execute("SELECT MD5(CAST((ARRAY_AGG(" . $this->table . ".* ORDER BY " . implode(',', $primary_key) . ")) AS TEXT)) FROM " . $this->table); + return $sth->fetchColumn(0); + } } - $sth = $db->execute("CHECKSUM TABLE " . $this->table . ';'); - $result = $sth->fetch('assoc'); - $checksum = $result['Checksum']; - - return $checksum; + // Have no better idea right now to make it always regenerate the tables + return microtime(); } /** From 1d5fefff0d2b696f4b450f94336c121208ab5fc3 Mon Sep 17 00:00:00 2001 From: Matthias Wirtz <2990373+swiffer@users.noreply.github.com> Date: Sun, 29 Dec 2019 06:56:34 +0100 Subject: [PATCH 04/11] Update ChecksumTestFixture.php --- src/TestSuite/Fixture/ChecksumTestFixture.php | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index dc122b4..f0010ed 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -26,15 +26,9 @@ class ChecksumTestFixture extends TestFixture protected static $_tableHashes = []; /** - * Inserts records in the database - * - * This will only happen if the underlying table is modified in any way or - * does not exist with a hash yet. - * - * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance - * @return bool + * @inheritDoc */ - public function insert(ConnectionInterface $db): bool + public function insert(ConnectionInterface $db) { if ($this->_tableUnmodified($db)) { return true; @@ -47,12 +41,7 @@ public function insert(ConnectionInterface $db): bool } /** - * Deletes all table information. - * - * This will only happen if the underlying table is modified in any way - * - * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance - * @return bool + * @inheritDoc */ public function truncate(ConnectionInterface $db): bool { @@ -64,10 +53,7 @@ public function truncate(ConnectionInterface $db): bool } /** - * Drops the table from the test datasource - * - * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance - * @return bool + * @inheritDoc */ public function drop(ConnectionInterface $db): bool { @@ -113,11 +99,13 @@ protected function _hash(ConnectionInterface $db): string if ($driver instanceof Mysql) { $sth = $db->execute("CHECKSUM TABLE " . $this->table . ';'); + return $sth->fetchColumn(0); } elseif ($driver instanceof Postgres) { $primary_key = $this->getTableSchema()->getPrimaryKey(); if (!empty($primary_key)) { $sth = $db->execute("SELECT MD5(CAST((ARRAY_AGG(" . $this->table . ".* ORDER BY " . implode(',', $primary_key) . ")) AS TEXT)) FROM " . $this->table); + return $sth->fetchColumn(0); } } From 1759c47c5c09b811e1e77eaec3fb9e5f3d17363b Mon Sep 17 00:00:00 2001 From: Matthias Wirtz <2990373+swiffer@users.noreply.github.com> Date: Sun, 29 Dec 2019 08:12:56 +0100 Subject: [PATCH 05/11] Update ChecksumTestFixture.php --- src/TestSuite/Fixture/ChecksumTestFixture.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index f0010ed..8101a8c 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -98,9 +98,9 @@ protected function _hash(ConnectionInterface $db): string $driver = $db->getDriver(); if ($driver instanceof Mysql) { - $sth = $db->execute("CHECKSUM TABLE " . $this->table . ';'); + $sth = $db->execute("CHECKSUM TABLE " . $this->table); - return $sth->fetchColumn(0); + return $sth->fetchColumn(1); } elseif ($driver instanceof Postgres) { $primary_key = $this->getTableSchema()->getPrimaryKey(); if (!empty($primary_key)) { From 4f90a6d30ba4268ef54e5da56048f2014fd75721 Mon Sep 17 00:00:00 2001 From: Matthias Wirtz <2990373+swiffer@users.noreply.github.com> Date: Sun, 29 Dec 2019 08:40:08 +0100 Subject: [PATCH 06/11] account for empty table --- src/TestSuite/Fixture/ChecksumTestFixture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index 8101a8c..3a08640 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -106,7 +106,7 @@ protected function _hash(ConnectionInterface $db): string if (!empty($primary_key)) { $sth = $db->execute("SELECT MD5(CAST((ARRAY_AGG(" . $this->table . ".* ORDER BY " . implode(',', $primary_key) . ")) AS TEXT)) FROM " . $this->table); - return $sth->fetchColumn(0); + return $sth->fetchColumn(0) ?: 'empty'; } } From 81ac6251cdb496b2dabbdf965bd03db702003bde Mon Sep 17 00:00:00 2001 From: Matthias Wirtz <2990373+swiffer@users.noreply.github.com> Date: Sun, 29 Dec 2019 11:11:05 +0100 Subject: [PATCH 07/11] Update ChecksumTestFixture.php revert add support for postgres. this does not work when a table changes that has foreign key constraints. --- src/TestSuite/Fixture/ChecksumTestFixture.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index 3a08640..58c2f8f 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -4,7 +4,6 @@ namespace FriendsOfCake\Fixturize\TestSuite\Fixture; use Cake\Database\Driver\Mysql; -use Cake\Database\Driver\Postgres; use Cake\Datasource\ConnectionInterface; use Cake\TestSuite\Fixture\TestFixture; @@ -101,13 +100,6 @@ protected function _hash(ConnectionInterface $db): string $sth = $db->execute("CHECKSUM TABLE " . $this->table); return $sth->fetchColumn(1); - } elseif ($driver instanceof Postgres) { - $primary_key = $this->getTableSchema()->getPrimaryKey(); - if (!empty($primary_key)) { - $sth = $db->execute("SELECT MD5(CAST((ARRAY_AGG(" . $this->table . ".* ORDER BY " . implode(',', $primary_key) . ")) AS TEXT)) FROM " . $this->table); - - return $sth->fetchColumn(0) ?: 'empty'; - } } // Have no better idea right now to make it always regenerate the tables From e86f1030de96659c872b6f327a5b545ecb10b4ca Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sun, 29 Dec 2019 14:08:58 +0100 Subject: [PATCH 08/11] add comments back --- src/TestSuite/Fixture/ChecksumTestFixture.php | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index 58c2f8f..44d7374 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -25,7 +25,15 @@ class ChecksumTestFixture extends TestFixture protected static $_tableHashes = []; /** - * @inheritDoc + * Inserts records in the database + * + * This will only happen if the underlying table is modified in any way or + * does not exist with a hash yet. + * + * @param \Cake\Datasource\ConnectionInterface $db An instance of the connection + * into which the records will be inserted. + * @return \Cake\Database\StatementInterface|bool on success or if there are no records to insert, + * or false on failure. */ public function insert(ConnectionInterface $db) { @@ -40,7 +48,12 @@ public function insert(ConnectionInterface $db) } /** - * @inheritDoc + * Deletes all table information. + * + * This will only happen if the underlying table is modified in any way + * + * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance + * @return bool */ public function truncate(ConnectionInterface $db): bool { @@ -52,7 +65,10 @@ public function truncate(ConnectionInterface $db): bool } /** - * @inheritDoc + * Drops the table from the test datasource + * + * @param \Cake\Datasource\ConnectionInterface $db An instance of the connection the fixture should be removed from. + * @return bool True on success, false on failure. */ public function drop(ConnectionInterface $db): bool { @@ -101,7 +117,6 @@ protected function _hash(ConnectionInterface $db): string return $sth->fetchColumn(1); } - // Have no better idea right now to make it always regenerate the tables return microtime(); } From 788d2124d0213a608bbafa57fc04b7d0e962dd82 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 23 Feb 2023 08:12:22 +0530 Subject: [PATCH 09/11] Update readme --- README.md | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/README.md b/README.md index 43c97f0..11096d1 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ # Installation -For CakePHP 3.x compatible version: - ``` composer require friendsofcake/fixturize ``` @@ -51,20 +49,4 @@ Re-run your tests and enjoy the speed! -Feel free to submit your own results above - -# Bugs - -If you happen to stumble upon a bug, please feel free to create a pull request with a fix -(optionally with a test), and a description of the bug and how it was resolved. - -You can also create an issue with a description to raise awareness of the bug. - -# Features - -If you have a good idea for a Fixturize feature, please join us on IRC and let's discuss it. Pull -requests are always more than welcome. - -# Support / Questions - -You can join us on IRC in the #CakePHP channel for any support or questions. +Feel free to submit your own results above. From accaa5a485fd12a433f1ccfce472b466535eea7a Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 23 Feb 2023 08:25:06 +0530 Subject: [PATCH 10/11] Add CI --- .editorconfig | 4 +++ .github/workflows/ci.yml | 29 +++++++++++++++++++ composer.json | 5 ++++ phpstan.neon | 4 +++ src/TestSuite/Fixture/ChecksumTestFixture.php | 6 ++-- 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 phpstan.neon diff --git a/.editorconfig b/.editorconfig index bd0ddd7..13d94df 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,7 @@ trim_trailing_whitespace = true [*.yml] indent_style = space indent_size = 2 + +[*.neon] +indent_style = tab +indent_size = 4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bc30100 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: [push, pull_request] + +jobs: + cs-stan: + name: Coding Standard & Static Analysis + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: mbstring, intl + coverage: none + tools: phpstan:1.10, cs2pr + + - name: Composer Install + run: composer install + + - name: Run phpcs + run: vendor/bin/phpcs --report=checkstyle --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ | cs2pr + + - name: Run phpstan + if: always() + run: phpstan analyse --error-format=github diff --git a/composer.json b/composer.json index 7495eba..19322b4 100644 --- a/composer.json +++ b/composer.json @@ -43,5 +43,10 @@ "source": "https://github.com/FriendsOfCake/fixturize", "issues": "https://github.com/FriendsOfCake/fixturize/issues", "irc": "irc://irc.freenode.org/cakephp" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..c308dcf --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 8 + paths: + - src diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index 44d7374..f88c099 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -13,14 +13,13 @@ * * If no data has changed, the usual truncate/insert flow is bypassed, increasing the speed * of the test suite with heavy fixture usage up significantly. - * */ class ChecksumTestFixture extends TestFixture { /** * List of table hashes * - * @var array + * @var array */ protected static $_tableHashes = []; @@ -113,10 +112,11 @@ protected function _hash(ConnectionInterface $db): string $driver = $db->getDriver(); if ($driver instanceof Mysql) { - $sth = $db->execute("CHECKSUM TABLE " . $this->table); + $sth = $db->execute('CHECKSUM TABLE ' . $this->table); return $sth->fetchColumn(1); } + // Have no better idea right now to make it always regenerate the tables return microtime(); } From 6282a6d5ca90a9ed79191d29efdb7f25a37af95a Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 23 Feb 2023 08:39:30 +0530 Subject: [PATCH 11/11] Quote table name. --- src/TestSuite/Fixture/ChecksumTestFixture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestSuite/Fixture/ChecksumTestFixture.php b/src/TestSuite/Fixture/ChecksumTestFixture.php index f88c099..d26f0d8 100644 --- a/src/TestSuite/Fixture/ChecksumTestFixture.php +++ b/src/TestSuite/Fixture/ChecksumTestFixture.php @@ -112,7 +112,7 @@ protected function _hash(ConnectionInterface $db): string $driver = $db->getDriver(); if ($driver instanceof Mysql) { - $sth = $db->execute('CHECKSUM TABLE ' . $this->table); + $sth = $db->execute('CHECKSUM TABLE `' . $this->table . '`'); return $sth->fetchColumn(1); }