From 121014c7c062224b41d56eefa12c1257caca4807 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Tue, 5 Oct 2010 23:34:44 -0400 Subject: [PATCH] Remove less-than-half complete Oracle and MS-SQL support (both are in branches for anyone to pick up later) --- framework/Db/lib/Horde/Db/Adapter/Mssql/Schema.php | 168 --------------------- framework/Db/lib/Horde/Db/Adapter/Oci8.php | 88 ----------- .../Db/lib/Horde/Db/Adapter/Oracle/Schema.php | 91 ----------- framework/Db/lib/Horde/Db/Adapter/Pdo/Oci.php | 145 ------------------ framework/Db/package.xml | 15 -- 5 files changed, 507 deletions(-) delete mode 100644 framework/Db/lib/Horde/Db/Adapter/Mssql/Schema.php delete mode 100644 framework/Db/lib/Horde/Db/Adapter/Oci8.php delete mode 100644 framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php delete mode 100644 framework/Db/lib/Horde/Db/Adapter/Pdo/Oci.php diff --git a/framework/Db/lib/Horde/Db/Adapter/Mssql/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Mssql/Schema.php deleted file mode 100644 index 5406d5698..000000000 --- a/framework/Db/lib/Horde/Db/Adapter/Mssql/Schema.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ - -/** - * @author Mike Naberezny - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ -class Horde_Db_Adapter_Mssql_Schema extends Horde_Db_Adapter_Base_Schema -{ - /*########################################################################## - # Quoting - ##########################################################################*/ - - /** - * @return string - */ - public function quoteColumnName($name) - { - return '[' . str_replace(']', ']]', $name) . ']'; - } - - - /*########################################################################## - # Schema Statements - ##########################################################################*/ - - /** - * The db column types for this adapter - * - * @return array - */ - public function nativeDatabaseTypes() - { - return array( - /* TODO, just put in nchar for unicode strings */ - 'primaryKey' => 'int(11) DEFAULT NULL IDENTITY PRIMARY KEY', - 'string' => array('name' => 'nchar', 'limit' => 255), - 'text' => array('name' => 'text', 'limit' => null), - 'integer' => array('name' => 'int', 'limit' => 11), - 'float' => array('name' => 'float', 'limit' => null), - 'decimal' => array('name' => 'decimal', 'limit' => null), - 'datetime' => array('name' => 'datetime', 'limit' => null), - 'timestamp' => array('name' => 'datetime', 'limit' => null), - 'time' => array('name' => 'time', 'limit' => null), - 'date' => array('name' => 'date', 'limit' => null), - 'binary' => array('name' => 'blob', 'limit' => null), - 'boolean' => array('name' => 'tinyint', 'limit' => 1), - ); - } - - - /** - */ - public function tables($name = null) - { - return 'SELECT name FROM sysobjects WHERE type = \'U\' ORDER BY name'; - } - - /** - */ - protected function _limit($query, &$sql, &$bindParams) - { - if ($query->limit) { - $orderby = stristr($sql, 'ORDER BY'); - if ($orderby !== false) { - $sort = (stripos($orderby, 'DESC') !== false) ? 'DESC' : 'ASC'; - $order = str_ireplace('ORDER BY', '', $orderby); - $order = trim(preg_replace('/ASC|DESC/i', '', $order)); - } - - $sql = preg_replace('/^SELECT /i', 'SELECT TOP ' . ($query->limit + $query->limitOffset) . ' ', $sql); - - $sql = 'SELECT * FROM (SELECT TOP ' . $query->limit . ' * FROM (' . $sql . ') AS inner_tbl'; - if ($orderby !== false) { - $sql .= ' ORDER BY ' . $order . ' '; - $sql .= (stripos($sort, 'ASC') !== false) ? 'DESC' : 'ASC'; - } - $sql .= ') AS outer_tbl'; - if ($orderby !== false) { - $sql .= ' ORDER BY ' . $order . ' ' . $sort; - } - } - } - - /** - * Get a description of the database table that $model is going to - * reflect. - */ - public function loadModel($model) - { - $tblinfo = $this->select('EXEC sp_columns @table_name = ' . $this->dml->quoteColumnName($model->table)); - while ($col = $tblinfo->fetch()) { - if (strpos($col['type_name'], ' ') !== false) { - list($type, $identity) = explode(' ', $col['type_name']); - } else { - $type = $col['type_name']; - $identity = ''; - } - - $model->addField($col['column_name'], array('type' => $type, - 'null' => !(bool)$col['is_nullable'] == 'NO', - 'default' => $col['column_def'])); - if (strtolower($identity) == 'identity') { - $model->key = $col['column_name']; - } - } - } - - /** - */ - protected function _lastInsertId($sequence) - { - return $this->selectOne('SELECT @@IDENTITY'); - } - - /** - * Changes the column of a table. - */ - public function changeColumn($tableName, $columnName, $type, - $options = array()) - { - parent::changeColumn($tableName, $columnName, $type, $options); - - if (!empty($options['autoincrement'])) { - /* Can't alter column in table - need to create, remove old - * column, and rename: - * http://www.eggheadcafe.com/software/aspnet/30132263/alter-table-add-identity.aspx */ - // TODO: Better temp name? - $this->addColumn($tableName, $columnName . '_temp', $type, $options); - $this->removeColumn($tableName, $columnName); - $this->renameColumn($tableName, $columnName . '_temp', $columnName); - } - } - - /** - * Add additional column options. - * - * @param string $sql - * @param array $options - * @return string - */ - public function addColumnOptions($sql, $options) - { - $sql = parent::addColumnOptions($sql, $options); - if (!empty($options['autoincrement'])) { - $sql .= ' IDENTITY'; - } - return $sql; - } - - -} diff --git a/framework/Db/lib/Horde/Db/Adapter/Oci8.php b/framework/Db/lib/Horde/Db/Adapter/Oci8.php deleted file mode 100644 index c25423230..000000000 --- a/framework/Db/lib/Horde/Db/Adapter/Oci8.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ - -/* -I have been exploring ZF to implement for my client and found a few -interesting things that I thought might be of interest to others using -the Oracle oci8 driver. While not really "broken", the support for the -Oracle oci8 driver does appear to be missing a few useful / convenient -features: - -The Zend_Db_Oracle driver ignores the 'host' parameter. This is only -an issue when PHP is compiled with Oracles instant client which need -not use TNS. For instance the following $dsn throws the following -exception "TNS:could not resolve the connect identifier specified" - -Fails: - -$dsn = array( - 'host' =>'myhost', - 'username' => 'zend', - 'password' => 'zend', - 'dbname' => 'xe', - 'options' => $options -); - -This is not surprising since the instant client does not use TNS as -stated. To get this to work you need to prepend the 'dbname' parameter -with the host name, which although easy to do is not very intuitive. - -Works: - -$dsn = array( - 'host' => 'totally ignored', - 'username' => 'zend', - 'password' => 'zend', - 'dbname' => 'myhost/xe', - 'options' => $options -); - -Zend_Db_Statement_Oracle - -This class states that it does not support case folding due to a -limitation of the Oci8 driver. The driver may not support case -folding, but after a quick review of the code I was curious as to why -this was not emulated, at least for results being returned as an -associative array (objects would not be much of a stretch either)? -This would be a great feature to have and save those looking for this -feature from having to call the array_change_key_case() function on -every row returned J -*/ - -/** - * @author Mike Naberezny - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ -class Horde_Db_Adapter_Oci8 extends Horde_Db_Adapter_Base -{ - /** - * @var string - */ - protected $_schemaClass = 'Horde_Db_Adapter_Oracle_Schema'; - - /** - * Build a connection string and connect to the database server. - * - * @TODO http://blogs.oracle.com/opal/discuss/msgReader$111 - */ - public function connect() - { - } - -} diff --git a/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php deleted file mode 100644 index af9299f78..000000000 --- a/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ - -/** - * @author Mike Naberezny - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ -class Horde_Db_Adapter_Oracle_Schema extends Horde_Db_Adapter_Base_Schema -{ - /*########################################################################## - # Quoting - ##########################################################################*/ - - /** - * @return string - */ - public function quoteColumnName($name) - { - return '"' . str_replace('"', '""', $name) . '"'; - } - - /** - * Adds a new column to the named table. - * See TableDefinition#column for details of the options you can use. - * - * @throws Horde_Db_Exception - */ - public function addColumn($tableName, $columnName, $type, - $options = array()) - { - parent::addColumn($tableName, $columnName, $type, $options); - - if (!empty($options['autoincrement'])) { - $this->_autoSequenceColumn($tableName, $columnName); - } - } - - /** - * Changes the column of a table. - * - * @throws Horde_Db_Exception - */ - public function changeColumn($tableName, $columnName, $type, - $options = array()) - { - parent::changeColumn($tableName, $columnName, $type, $options); - - if (!empty($options['autoincrement'])) { - $this->_autoSequenceColumn($tableName, $columnName); - } - } - - /** - * Add auto-sequencing to a column. - * - * @throws Horde_Db_Exception - */ - protected function _autoSequenceColumn($tableName, $columnName) - { - $seq_name = $tableName . '_' . $columnName . '_seq'; - $trigger_name = $tableName . '_' . $columnName . '_trigger'; - - $this->beginDbTransaction(); - $this->execute('CREATE SEQUENCE ' . $seq_name); - $this->execute( - 'CREATE TRIGGER ' . $trigger_name . ' ' . - 'BEFORE INSERT ON ' . $this->quoteTableName($tableName) . ' ' . - 'FOR EACH ROW ' . - 'BEGIN ' . - 'SELECT ' . $seq_name . '.nextval INTO :new.' . $columnName . ' FROM dual; END' - ); - $this->commitDbTransaction(); - } - -} diff --git a/framework/Db/lib/Horde/Db/Adapter/Pdo/Oci.php b/framework/Db/lib/Horde/Db/Adapter/Pdo/Oci.php deleted file mode 100644 index 6d88b0703..000000000 --- a/framework/Db/lib/Horde/Db/Adapter/Pdo/Oci.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ - -/* -I have been exploring ZF to implement for my client and found a few -interesting things that I thought might be of interest to others using -the Oracle oci8 driver. While not really "broken", the support for the -Oracle oci8 driver does appear to be missing a few useful / convenient -features: - -The Zend_Db_Oracle driver ignores the 'host' parameter. This is only -an issue when PHP is compiled with Oracles instant client which need -not use TNS. For instance the following $dsn throws the following -exception "TNS:could not resolve the connect identifier specified" - -Fails: - -$dsn = array( - 'host' =>'myhost', - 'username' => 'zend', - 'password' => 'zend', - 'dbname' => 'xe', - 'options' => $options -); - -This is not surprising since the instant client does not use TNS as -stated. To get this to work you need to prepend the 'dbname' parameter -with the host name, which although easy to do is not very intuitive. - -Works: - -$dsn = array( - 'host' => 'totally ignored', - 'username' => 'zend', - 'password' => 'zend', - 'dbname' => 'myhost/xe', - 'options' => $options -); - -Zend_Db_Statement_Oracle - -This class states that it does not support case folding due to a -limitation of the Oci8 driver. The driver may not support case -folding, but after a quick review of the code I was curious as to why -this was not emulated, at least for results being returned as an -associative array (objects would not be much of a stretch either)? -This would be a great feature to have and save those looking for this -feature from having to call the array_change_key_case() function on -every row returned J -*/ - -/** - * OCI PDO Horde_Db_Adapter - * - * @author Mike Naberezny - * @author Derek DeVries - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php - * @category Horde - * @package Horde_Db - * @subpackage Adapter - */ -class Horde_Db_Adapter_Pdo_Oci extends Horde_Db_Adapter_Pdo_Base -{ - /** - * @var string - */ - protected $_schemaClass = 'Horde_Db_Adapter_Oracle_Schema'; - - /** - * Get the appropriate DML object and call the parent constructor. - * - * @param array $options Connection options. - */ - public function __construct($options = array()) - { - parent::__construct($options); - } - - /** - * @return string - */ - public function adapterName() - { - return 'PDO_Oci'; - } - - /** - * Get a description of the database table that $model is going to - * reflect. - */ - public function loadModel($model) - { - $table = $this->dml->quoteColumnName(strtoupper($model->table)); - $tblinfo = $this->select('SELECT column_name, data_type, data_length, nullable, data_default FROM all_tab_columns WHERE table_name = ' - . $table); - while ($col = $tblinfo->fetch()) { - $model->addField($col['column_name'], array('type' => $col['data_type'], - 'null' => ($col['nullable'] != 'N'), - 'default' => $col['data_default'], - 'length' => $col['data_length'])); - } - - // Only fetch the first primary key for now. - $model->key = $this->selectOne('SELECT DISTINCT b.column_name FROM all_constraints a, all_cons_columns b WHERE a.table_name = ' - . $table . ' AND a.constraint_type = \'P\' AND b.constraint_name = a.constraint_name'); - } - - /** - */ - protected function _lastInsertId($sequence) - { - $data = $this->selectOne('SELECT ' . $this->dml->quoteColumnName($sequence) . '.currval FROM dual'); - } - - /** - */ - public function getTables() - { - return 'SELECT table_name FROM all_tables'; - } - - /** - */ - protected function _limit($query, &$sql, &$bindParams) - { - if ($query->limit) { - - $sql = 'SELECT q2.* FROM (SELECT rownum r, q1.* FROM (' . $sql . ') q1) q2 - WHERE r BETWEEN ' . $query->limitOffset . ' AND ' . ($query->limit + $query->limitOffset); - } - } - -} diff --git a/framework/Db/package.xml b/framework/Db/package.xml index eea178470..d30857804 100644 --- a/framework/Db/package.xml +++ b/framework/Db/package.xml @@ -47,9 +47,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - @@ -61,13 +58,9 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - @@ -77,7 +70,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - @@ -128,8 +120,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - @@ -138,13 +128,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - -- 2.11.0