Source for file Oracle.php
Documentation is available at Oracle.php
* $Id: Mock.php 1080 2007-02-10 18:17:08Z romanb $
* 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
* OWNER 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.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
* Doctrine_Adapter_Oracle
* [BORROWED FROM ZEND FRAMEWORK]
* @subpackage Doctrine_Adapter
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @version $Revision: 1080 $
* User-provided configuration.
* username => (string) Connect to the database as this username.
* password => (string) Password associated with the username.
* dbname => Either the name of the local Oracle instance, or the
* name of the entry in tnsnames.ora to which you want to connect.
* $config is an array of key/value pairs containing configuration
* options. These options are common to most adapters:
* username => (string) Connect to the database as this username.
* password => (string) Password associated with the username.
* dbname => Either the name of the local Oracle instance, or the
* name of the entry in tnsnames.ora to which you want to connect.
* @param array $config An array of configuration keys.
* @throws Doctrine_Adapter_Exception
if ( ! isset
($config['password']) ||
! isset
($config['username'])) {
// @todo Let this protect backward-compatibility for one release, then remove
if ( ! isset
($config['database']) ||
! isset
($config['dbname'])) {
$config['dbname'] =
$config['database'];
unset
($config['database']);
trigger_error("Deprecated config key 'database', use 'dbname' instead.", E_USER_NOTICE);
// create a profiler object
$enabled = (bool)
$this->_config['profiler'];
$this->_profiler =
new Doctrine_Profiler($enabled);
* Creates a connection resource.
* @throws Doctrine_Adapter_Oracle_Exception
// connection already exists
throw
new Doctrine_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but not loaded');
if (isset
($this->_config['dbname'])) {
$this->_connection =
@oci_connect(
$this->_connection =
oci_connect(
if (!$this->_connection) {
throw
new Doctrine_Adapter_Oracle_Exception(oci_error());
* Force the connection to close.
oci_close($this->_connection);
$this->_connection =
null;
* Returns an SQL statement for preparation.
* @param string $sql The SQL statement with placeholders.
* @return Doctrine_Statement_Oracle
$stmt =
new Doctrine_Statement_Oracle($this, $sql);
* @param string $value Raw string
* @return string Quoted string
protected function _quote($value)
return "'" .
addcslashes($value, "\000\n\r\\\032") .
"'";
* Quote a table identifier and alias.
* @param string|array|Doctrine_Expr$ident The identifier or expression.
* @param string $alias An alias for the table.
* @return string The quoted identifier and alias.
// Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias.
return $this->_quoteIdentifierAs($ident, $alias, ' ');
* Leave autocommit mode and begin a transaction.
* Commit a transaction and return to autocommit mode.
* @throws Doctrine_Adapter_Oracle_Exception
if (!oci_commit($this->_connection)) {
throw
new Doctrine_Adapter_Oracle_Exception(oci_error($this->_connection));
* Roll back a transaction and return to autocommit mode.
* @throws Doctrine_Adapter_Oracle_Exception
if (!oci_rollback($this->_connection)) {
throw
new Doctrine_Adapter_Oracle_Exception(oci_error($this->_connection));
* @todo Support FETCH_CLASS and FETCH_INTO.
* @param integer $mode A fetch mode.
* @throws Doctrine_Adapter_Exception
case Doctrine::FETCH_ASSOC:
// assoc array
case Doctrine::FETCH_BOTH:
// seq+assoc array
$this->_fetchMode =
$mode;
* @throws Doctrine_Adapter_Exception
case OCI_COMMIT_ON_SUCCESS: