⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oci8.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: *//** * The PEAR DB driver for PHP's oci8 extension * for interacting with Oracle databases * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt.  If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category   Database * @package    DB * @author     James L. Pine <jlp@valinux.com> * @author     Daniel Convissor <danielc@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    CVS: $Id: oci8.php,v 1.103 2005/04/11 15:10:22 danielc Exp $ * @link       http://pear.php.net/package/DB *//** * Obtain the DB_common class so it can be extended from */require_once 'DB/common.php';/** * The methods PEAR DB uses to interact with PHP's oci8 extension * for interacting with Oracle databases * * Definitely works with versions 8 and 9 of Oracle. * * These methods overload the ones declared in DB_common. * * Be aware...  OCIError() only appears to return anything when given a * statement, so functions return the generic DB_ERROR instead of more * useful errors that have to do with feedback from the database. * * @category   Database * @package    DB * @author     James L. Pine <jlp@valinux.com> * @author     Daniel Convissor <danielc@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    Release: 1.7.6 * @link       http://pear.php.net/package/DB */class DB_oci8 extends DB_common{    // {{{ properties    /**     * The DB driver type (mysql, oci8, odbc, etc.)     * @var string     */    var $phptype = 'oci8';    /**     * The database syntax variant to be used (db2, access, etc.), if any     * @var string     */    var $dbsyntax = 'oci8';    /**     * The capabilities of this DB implementation     *     * The 'new_link' element contains the PHP version that first provided     * new_link support for this DBMS.  Contains false if it's unsupported.     *     * Meaning of the 'limit' element:     *   + 'emulate' = emulate with fetch row by number     *   + 'alter'   = alter the query     *   + false     = skip rows     *     * @var array     */    var $features = array(        'limit'         => 'alter',        'new_link'      => '5.0.0',        'numrows'       => 'subquery',        'pconnect'      => true,        'prepare'       => true,        'ssl'           => false,        'transactions'  => true,    );    /**     * A mapping of native error codes to DB error codes     * @var array     */    var $errorcode_map = array(        1    => DB_ERROR_CONSTRAINT,        900  => DB_ERROR_SYNTAX,        904  => DB_ERROR_NOSUCHFIELD,        913  => DB_ERROR_VALUE_COUNT_ON_ROW,        921  => DB_ERROR_SYNTAX,        923  => DB_ERROR_SYNTAX,        942  => DB_ERROR_NOSUCHTABLE,        955  => DB_ERROR_ALREADY_EXISTS,        1400 => DB_ERROR_CONSTRAINT_NOT_NULL,        1401 => DB_ERROR_INVALID,        1407 => DB_ERROR_CONSTRAINT_NOT_NULL,        1418 => DB_ERROR_NOT_FOUND,        1476 => DB_ERROR_DIVZERO,        1722 => DB_ERROR_INVALID_NUMBER,        2289 => DB_ERROR_NOSUCHTABLE,        2291 => DB_ERROR_CONSTRAINT,        2292 => DB_ERROR_CONSTRAINT,        2449 => DB_ERROR_CONSTRAINT,    );    /**     * The raw database connection created by PHP     * @var resource     */    var $connection;    /**     * The DSN information for connecting to a database     * @var array     */    var $dsn = array();    /**     * Should data manipulation queries be committed automatically?     * @var bool     * @access private     */    var $autocommit = true;    /**     * Stores the $data passed to execute() in the oci8 driver     *     * Gets reset to array() when simpleQuery() is run.     *     * Needed in case user wants to call numRows() after prepare/execute     * was used.     *     * @var array     * @access private     */    var $_data = array();    /**     * The result or statement handle from the most recently executed query     * @var resource     */    var $last_stmt;    /**     * Is the given prepared statement a data manipulation query?     * @var array     * @access private     */    var $manip_query = array();    // }}}    // {{{ constructor    /**     * This constructor calls <kbd>$this->DB_common()</kbd>     *     * @return void     */    function DB_oci8()    {        $this->DB_common();    }    // }}}    // {{{ connect()    /**     * Connect to the database server, log in and open the database     *     * Don't call this method directly.  Use DB::connect() instead.     *     * If PHP is at version 5.0.0 or greater:     *   + Generally, oci_connect() or oci_pconnect() are used.     *   + But if the new_link DSN option is set to true, oci_new_connect()     *     is used.     *     * When using PHP version 4.x, OCILogon() or OCIPLogon() are used.     *     * PEAR DB's oci8 driver supports the following extra DSN options:     *   + charset       The character set to be used on the connection.     *                    Only used if PHP is at version 5.0.0 or greater     *                    and the Oracle server is at 9.2 or greater.     *                    Available since PEAR DB 1.7.0.     *   + new_link      If set to true, causes subsequent calls to     *                    connect() to return a new connection link     *                    instead of the existing one.  WARNING: this is     *                    not portable to other DBMS's.     *                    Available since PEAR DB 1.7.0.     *     * @param array $dsn         the data source name     * @param bool  $persistent  should the connection be persistent?     *     * @return int  DB_OK on success. A DB_Error object on failure.     */    function connect($dsn, $persistent = false)    {        if (!PEAR::loadExtension('oci8')) {            return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);        }        $this->dsn = $dsn;        if ($dsn['dbsyntax']) {            $this->dbsyntax = $dsn['dbsyntax'];        }        if (function_exists('oci_connect')) {            if (isset($dsn['new_link'])                && ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))            {                $connect_function = 'oci_new_connect';            } else {                $connect_function = $persistent ? 'oci_pconnect'                                    : 'oci_connect';            }            // Backwards compatibility with DB < 1.7.0            if (empty($dsn['database']) && !empty($dsn['hostspec'])) {                $db = $dsn['hostspec'];            } else {                $db = $dsn['database'];            }            $char = empty($dsn['charset']) ? null : $dsn['charset'];            $this->connection = @$connect_function($dsn['username'],                                                   $dsn['password'],                                                   $db,                                                   $char);            $error = OCIError();            if (!empty($error) && $error['code'] == 12541) {                // Couldn't find TNS listener.  Try direct connection.                $this->connection = @$connect_function($dsn['username'],                                                       $dsn['password'],                                                       null,                                                       $char);            }        } else {            $connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';            if ($dsn['hostspec']) {                $this->connection = @$connect_function($dsn['username'],                                                       $dsn['password'],                                                       $dsn['hostspec']);            } elseif ($dsn['username'] || $dsn['password']) {                $this->connection = @$connect_function($dsn['username'],                                                       $dsn['password']);            }        }        if (!$this->connection) {            $error = OCIError();            $error = (is_array($error)) ? $error['message'] : null;            return $this->raiseError(DB_ERROR_CONNECT_FAILED,                                     null, null, null,                                     $error);        }        return DB_OK;    }    // }}}    // {{{ disconnect()    /**     * Disconnects from the database server     *     * @return bool  TRUE on success, FALSE on failure     */    function disconnect()    {        if (function_exists('oci_close')) {            $ret = @oci_close($this->connection);        } else {            $ret = @OCILogOff($this->connection);        }        $this->connection = null;        return $ret;    }    // }}}    // {{{ simpleQuery()    /**     * Sends a query to the database server     *     * To determine how many rows of a result set get buffered using     * ocisetprefetch(), see the "result_buffering" option in setOptions().     * This option was added in Release 1.7.0.     *     * @param string  the SQL query string     *     * @return mixed  + a PHP result resrouce for successful SELECT queries     *                + the DB_OK constant for other successful queries     *                + a DB_Error object on failure     */    function simpleQuery($query)    {        $this->_data = array();        $this->last_parameters = array();        $this->last_query = $query;        $query = $this->modifyQuery($query);        $result = @OCIParse($this->connection, $query);        if (!$result) {            return $this->oci8RaiseError();        }        if ($this->autocommit) {            $success = @OCIExecute($result,OCI_COMMIT_ON_SUCCESS);        } else {            $success = @OCIExecute($result,OCI_DEFAULT);        }        if (!$success) {            return $this->oci8RaiseError($result);        }        $this->last_stmt = $result;        if (DB::isManip($query)) {            return DB_OK;        } else {            @ocisetprefetch($result, $this->options['result_buffering']);            return $result;        }    }    // }}}    // {{{ nextResult()    /**     * Move the internal oracle result pointer to the next available result     *     * @param a valid oci8 result resource     *     * @access public     *     * @return true if a result is available otherwise return false     */    function nextResult($result)    {        return false;    }    // }}}    // {{{ fetchInto()    /**     * Places a row from the result set into the given array     *     * Formating of the array and the data therein are configurable.     * See DB_result::fetchInto() for more information.     *     * This method is not meant to be called directly.  Use     * DB_result::fetchInto() instead.  It can't be declared "protected"     * because DB_result is a separate object.     *     * @param resource $result    the query result resource     * @param array    $arr       the referenced array to put the data in     * @param int      $fetchmode how the resulting array should be indexed     * @param int      $rownum    the row number to fetch (0 = first row)     *     * @return mixed  DB_OK on success, NULL when the end of a result set is     *                 reached or on failure     *     * @see DB_result::fetchInto()     */    function fetchInto($result, &$arr, $fetchmode, $rownum = null)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -