From 11f59463fdb8ba49d1066aacd63a4c551b28a84e Mon Sep 17 00:00:00 2001 From: Holger Schletz Date: Fri, 28 Oct 2022 19:55:24 +0200 Subject: [PATCH] Remove support for outdated DBAL. --- README.md | 8 ++-- src/Factory.php | 6 --- src/Link/Mdb2.php | 101 ------------------------------------------- src/Link/ZendDb.php | 89 -------------------------------------- src/Link/ZendDb2.php | 88 ------------------------------------- 5 files changed, 3 insertions(+), 289 deletions(-) delete mode 100644 src/Link/Mdb2.php delete mode 100644 src/Link/ZendDb.php delete mode 100644 src/Link/ZendDb2.php diff --git a/README.md b/README.md index e5f510a..7ecc94a 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,9 @@ About NADA NADA is a high level SQL abstraction library for PHP. It complements and operates on top of a conventional database abstraction layer (currently -supported: [PDO](http://php.net/manual/en/book.pdo.php), -[Zend_Db (Zend Framework 1.x)](http://framework.zend.com), -[Zend\Db (Zend Framework 2.x)](http://framework.zend.com) and -[MDB2](http://pear.php.net/package/MDB2)), allowing easy integration into -existing applications. +supported: [PDO](http://php.net/manual/en/book.pdo.php) and +[Laminas-DB](https://docs.laminas.dev/laminas-db/)), allowing easy integration +into existing applications. NADA provides SQL abstraction methods for different database backends (currently supported: [PostgreSQL](http://postgresql.org), [MySQL](http://mysql.org) and diff --git a/src/Factory.php b/src/Factory.php index c7686a2..c40acc3 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -59,12 +59,6 @@ static function getDatabase($link) $class = 'Pdo'; } elseif ($link instanceof \Laminas\Db\Adapter\Adapter) { $class = 'LaminasDb'; - } elseif ($link instanceof \Zend\Db\Adapter\Adapter) { - $class = 'ZendDb2'; - } elseif ($link instanceof \Zend_Db_Adapter_Abstract) { - $class = 'ZendDb'; - } elseif ($link instanceof \MDB2_Driver_Common) { - $class = 'Mdb2'; } else { throw new \InvalidArgumentException('Unsupported link type'); } diff --git a/src/Link/Mdb2.php b/src/Link/Mdb2.php deleted file mode 100644 index ec06916..0000000 --- a/src/Link/Mdb2.php +++ /dev/null @@ -1,101 +0,0 @@ - - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -namespace Nada\Link; - -/** - * Link to MDB2 based classes - * - * This class overrides methods with MDB2-specific implementations. - * @internal - */ -class Mdb2 extends AbstractLink -{ - - /** {@inheritdoc} */ - public function getDbmsSuffix() - { - switch ($this->_link->dbsyntax) { - case 'mysql': - return 'Mysql'; - case 'pgsql': - return 'Pgsql'; - default: - throw new \UnexpectedValueException('Unsupported DBMS type'); - } - } - - /** {@inheritdoc} */ - public function query($statement, $params) - { - $statement = $this->_link->prepare($statement, null, \MDB2_PREPARE_RESULT); - if (\PEAR::isError($statement)) { - throw new \RuntimeException($statement->getMessage()); - } - $result = $statement->execute($params); - if (\PEAR::isError($result)) { - throw new \RuntimeException($result->getMessage()); - } - - // Don't use fetchAll() because keys must be turned lowercase - $rowset = array(); - while ($row = $result->fetchRow(\MDB2_FETCHMODE_ASSOC)) { - foreach ($row as $column => $value) { - $output[strtolower($column)] = $value; - } - $rowset[] = $output; - } - return $rowset; - } - - /** {@inheritdoc} */ - public function exec($statement, $params) - { - $statement = $this->_link->prepare($statement, null, \MDB2_PREPARE_MANIP); - if (\PEAR::isError($statement)) { - throw new \RuntimeException($statement->getMessage()); - } - $result = $statement->execute($params); - if (\PEAR::isError($result)) { - throw new \RuntimeException($result->getMessage()); - } - return $result; - } - - /** {@inheritdoc} */ - public function quoteValue($value, $datatype) - { - return $this->_link->quote((string)$value); - } - - /** {@inheritdoc} */ - public function quoteIdentifier($identifier) - { - return $this->_link->quoteIdentifier($identifier); - } -} diff --git a/src/Link/ZendDb.php b/src/Link/ZendDb.php deleted file mode 100644 index 8ca1407..0000000 --- a/src/Link/ZendDb.php +++ /dev/null @@ -1,89 +0,0 @@ - - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -namespace Nada\Link; - -/** - * Link to Zend_Db_Adapter based classes - * - * This class overrides methods with ZendDb-specific implementations. - * @internal - */ -class ZendDb extends AbstractLink -{ - - /** {@inheritdoc} */ - public function getDbmsSuffix() - { - if ($this->_link instanceof \Zend_Db_Adapter_Pdo_Mysql) { - return 'Mysql'; - } elseif ($this->_link instanceof \Zend_Db_Adapter_Mysqli) { - return 'Mysql'; - } elseif ($this->_link instanceof \Zend_Db_Adapter_Pdo_Pgsql) { - return 'Pgsql'; - } elseif ($this->_link instanceof \Zend_Db_Adapter_Pdo_Sqlite) { - return 'Sqlite'; - } else { - throw new \UnexpectedValueException('Unsupported DBMS type'); - } - } - - /** {@inheritdoc} */ - public function query($statement, $params) - { - $statement = $this->_link->query($statement, $params); - - // Don't use fetchAll() because keys must be turned lowercase - $rowset = array(); - while ($row = $statement->fetch(\Zend_Db::FETCH_ASSOC)) { - foreach ($row as $column => $value) { - $output[strtolower($column)] = $value; - } - $rowset[] = $output; - } - return $rowset; - } - - /** {@inheritdoc} */ - public function exec($statement, $params) - { - return $this->_link->query($statement, $params)->rowCount(); - } - - /** {@inheritdoc} */ - public function quoteValue($value, $datatype) - { - return $this->_link->quote((string)$value); - } - - /** {@inheritdoc} */ - public function quoteIdentifier($identifier) - { - return $this->_link->quoteIdentifier($identifier); - } -} diff --git a/src/Link/ZendDb2.php b/src/Link/ZendDb2.php deleted file mode 100644 index 8ae4903..0000000 --- a/src/Link/ZendDb2.php +++ /dev/null @@ -1,88 +0,0 @@ - - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -namespace Nada\Link; - -/** - * Link to Zend\Db\Adapter\Adapter - * - * This class overrides methods with Zend\Db specific implementations. - * @internal - */ -class ZendDb2 extends AbstractLink -{ - - /** {@inheritdoc} */ - public function getDbmsSuffix() - { - switch ($this->_link->getDriver()->getDatabasePlatformName()) { - case 'Mysql': - return 'Mysql'; - case 'Postgresql': - return 'Pgsql'; - case 'Sqlite': - return 'Sqlite'; - default: - throw new \UnexpectedValueException('Unsupported DBMS type'); - } - } - - /** {@inheritdoc} */ - public function query($statement, $params) - { - $result = $this->_link->query($statement, $params); - - // Don't use toArray() because keys must be turned lowercase - $rowset = array(); - foreach ($result as $row) { - foreach ($row as $column => $value) { - $output[strtolower($column)] = $value; - } - $rowset[] = $output; - } - return $rowset; - } - - /** {@inheritdoc} */ - public function exec($statement, $params) - { - return $this->_link->query($statement, $params)->count(); - } - - /** {@inheritdoc} */ - public function quoteValue($value, $datatype) - { - return $this->_link->getPlatform()->quoteValue((string)$value); - } - - /** {@inheritdoc} */ - public function quoteIdentifier($identifier) - { - return $this->_link->getPlatform()->quoteIdentifier($identifier); - } -}