+++ /dev/null
-<?php
-/**
- * Copyright 2007 Maintainable Software, LLC
- * Copyright 2006-2010 The Horde Project (http://www.horde.org/)
- *
- * @author Mike Naberezny <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @license http://opensource.org/licenses/bsd-license.php
- * @category Horde
- * @package Horde_Db
- * @subpackage Adapter
- */
-
-/**
- * @author Mike Naberezny <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @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;
- }
-
-
-}
+++ /dev/null
-<?php
-/**
- * Copyright 2007 Maintainable Software, LLC
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
- *
- * @author Mike Naberezny <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @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 <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @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()
- {
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Copyright 2007 Maintainable Software, LLC
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
- *
- * @author Mike Naberezny <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @license http://opensource.org/licenses/bsd-license.php
- * @category Horde
- * @package Horde_Db
- * @subpackage Adapter
- */
-
-/**
- * @author Mike Naberezny <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @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();
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Copyright 2007 Maintainable Software, LLC
- * Copyright 2006-2010 The Horde Project (http://www.horde.org/)
- *
- * @author Mike Naberezny <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @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 <mike@maintainable.com>
- * @author Derek DeVries <derek@maintainable.com>
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @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);
- }
- }
-
-}
<file name="Table.php" role="php" />
<file name="TableDefinition.php" role="php" />
</dir> <!-- /lib/Horde/Db/Adapter/Base -->
- <dir name="Mssql">
- <file name="Schema.php" role="php" />
- </dir> <!-- /lib/Horde/Db/Adapter/Mssql -->
<dir name="Mysql">
<file name="Column.php" role="php" />
<file name="Result.php" role="php" />
<dir name="Pdo">
<file name="Base.php" role="php" />
<file name="Mysql.php" role="php" />
- <file name="Oci.php" role="php" />
<file name="Pgsql.php" role="php" />
<file name="Sqlite.php" role="php" />
</dir> <!-- /lib/Horde/Db/Adapter/Pdo -->
- <dir name="Oracle">
- <file name="Schema.php" role="php" />
- </dir> <!-- /lib/Horde/Db/Adapter/Oracle -->
<dir name="Postgresql">
<file name="Column.php" role="php" />
<file name="Schema.php" role="php" />
<file name="Schema.php" role="php" />
</dir> <!-- /lib/Horde/Db/Adapter/Sqlite -->
<file name="Base.php" role="php" />
- <file name="Oci8.php" role="php" />
<file name="Mysql.php" role="php" />
<file name="Mysqli.php" role="php" />
</dir> <!-- /lib/Horde/Db/Adapter -->
<install name="lib/Horde/Db/Adapter/Base/TableDefinition.php" as="Horde/Db/Adapter/Base/TableDefinition.php" />
<install name="lib/Horde/Db/Adapter/Base.php" as="Horde/Db/Adapter/Base.php" />
- <install name="lib/Horde/Db/Adapter/Mssql/Schema.php" as="Horde/Db/Adapter/Mssql/Schema.php" />
-
<install name="lib/Horde/Db/Adapter/Mysql/Column.php" as="Horde/Db/Adapter/Mysql/Column.php" />
<install name="lib/Horde/Db/Adapter/Mysql/Result.php" as="Horde/Db/Adapter/Mysql/Result.php" />
<install name="lib/Horde/Db/Adapter/Mysql/Schema.php" as="Horde/Db/Adapter/Mysql/Schema.php" />
<install name="lib/Horde/Db/Adapter/Mysqli/Result.php" as="Horde/Db/Adapter/Mysqli/Result.php" />
<install name="lib/Horde/Db/Adapter/Mysqli.php" as="Horde/Db/Adapter/Mysqli.php" />
- <install name="lib/Horde/Db/Adapter/Oci8.php" as="Horde/Db/Adapter/Oci8.php" />
-
- <install name="lib/Horde/Db/Adapter/Oracle/Schema.php" as="Horde/Db/Adapter/Oracle/Schema.php" />
-
<install name="lib/Horde/Db/Adapter/Pdo/Base.php" as="Horde/Db/Adapter/Pdo/Base.php" />
<install name="lib/Horde/Db/Adapter/Pdo/Mysql.php" as="Horde/Db/Adapter/Pdo/Mysql.php" />
- <install name="lib/Horde/Db/Adapter/Pdo/Oci.php" as="Horde/Db/Adapter/Pdo/Oci.php" />
<install name="lib/Horde/Db/Adapter/Pdo/Pgsql.php" as="Horde/Db/Adapter/Pdo/Pgsql.php" />
<install name="lib/Horde/Db/Adapter/Pdo/Sqlite.php" as="Horde/Db/Adapter/Pdo/Sqlite.php" />