From 3e97c51418e6d27e9a81906f347fcb7c78e27d4f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:23:16 +0200 Subject: Adding upstream version 0.20.0. Signed-off-by: Daniel Baumann --- vendor/gipfl/zfdb/src/Db.php | 248 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 vendor/gipfl/zfdb/src/Db.php (limited to 'vendor/gipfl/zfdb/src/Db.php') diff --git a/vendor/gipfl/zfdb/src/Db.php b/vendor/gipfl/zfdb/src/Db.php new file mode 100644 index 0000000..529461b --- /dev/null +++ b/vendor/gipfl/zfdb/src/Db.php @@ -0,0 +1,248 @@ +toArray(); + } + + /* + * Convert Zend_Config argument to plain string + * adapter name and separate config object. + */ + if ($adapter instanceof Zend_Config) { + if (isset($adapter->params)) { + $config = $adapter->params->toArray(); + } + if (isset($adapter->adapter)) { + $adapter = (string) $adapter->adapter; + } else { + $adapter = null; + } + } + + /* + * Verify that adapter parameters are in an array. + */ + if (!is_array($config)) { + throw new DbException('Adapter parameters must be in an array or a Zend_Config object'); + } + + /* + * Verify that an adapter name has been specified. + */ + if (!is_string($adapter) || empty($adapter)) { + throw new DbException('Adapter name must be specified in a string'); + } + + /* + * Form full adapter class name + */ + $adapterClass = '\\gipfl\\ZfDb\\Adapter\\' + . str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($adapter)))); + $dbAdapter = new $adapterClass($config); + + /* + * Verify that the object created is a descendent of the abstract adapter type. + */ + if (! $dbAdapter instanceof Adapter) { + throw new DbException("Adapter class '$adapterClass' does not extend gipfl\ZfDb\Abstract"); + } + + return $dbAdapter; + } +} -- cgit v1.2.3