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

📄 oracle.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category   Zend * @package    Zend_Db * @subpackage Statement * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License *//** * @see Zend_Db_Statement */require_once 'Zend/Db/Statement.php';/** * Extends for Oracle. * * @category   Zend * @package    Zend_Db * @subpackage Statement * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License */class Zend_Db_Statement_Oracle extends Zend_Db_Statement{    /**     * The connection_stmt object.     */    protected $_stmt;    /**     * Column names.     */    protected $_keys;    /**     * Fetched result values.     */    protected $_values;    /**     * Prepares statement handle     *     * @param string $sql     * @return void     * @throws Zend_Db_Statement_Oracle_Exception     */    protected function _prepare($sql)    {        $connection = $this->_adapter->getConnection();        $this->_stmt = oci_parse($connection, $sql);        if (!$this->_stmt) {            /**             * @see Zend_Db_Statement_Oracle_Exception             */            require_once 'Zend/Db/Statement/Oracle/Exception.php';            throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection));        }    }    /**     * Binds a parameter to the specified variable name.     *     * @param mixed $parameter Name the parameter, either integer or string.     * @param mixed $variable  Reference to PHP variable containing the value.     * @param mixed $type      OPTIONAL Datatype of SQL parameter.     * @param mixed $length    OPTIONAL Length of SQL parameter.     * @param mixed $options   OPTIONAL Other options.     * @return bool     * @throws Zend_Db_Statement_Exception     */    protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)    {        // default value        if ($type === NULL) {            $type = SQLT_CHR;        }        // default value        if ($length === NULL) {            $length = -1;        }        $retval = @oci_bind_by_name($this->_stmt, $parameter, $variable, $length, $type);        if ($retval === false) {            /**             * @see Zend_Db_Adapter_Oracle_Exception             */            require_once 'Zend/Db/Statement/Oracle/Exception.php';            throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));        }        return true;    }    /**     * Closes the cursor, allowing the statement to be executed again.     *     * @return bool     */    public function closeCursor()    {        if (!$this->_stmt) {            return false;        }        oci_free_statement($this->_stmt);        $this->_stmt = false;        return true;    }    /**     * Returns the number of columns in the result set.     * Returns null if the statement has no result set metadata.     *     * @return int The number of columns.     */    public function columnCount()    {        if (!$this->_stmt) {            return false;        }        return oci_num_fields($this->_stmt);    }    /**     * Retrieves the error code, if any, associated with the last operation on     * the statement handle.     *     * @return string error code.     */    public function errorCode()    {        if (!$this->_stmt) {            return false;        }        $error = oci_error($this->_stmt);        if (!$error) {            return false;        }        return $error['code'];    }    /**     * Retrieves an array of error information, if any, associated with the     * last operation on the statement handle.     *     * @return array     */    public function errorInfo()    {        if (!$this->_stmt) {            return false;        }        $error = oci_error($this->_stmt);        if (!$error) {            return false;        }        if (isset($error['sqltext'])) {            return array(                $error['code'],                $error['message'],                $error['offset'],                $error['sqltext'],            );        } else {            return array(                $error['code'],                $error['message'],            );        }    }    /**     * Executes a prepared statement.     *     * @param array $params OPTIONAL Values to bind to parameter placeholders.     * @return bool     * @throws Zend_Db_Statement_Exception     */    public function _execute(array $params = null)    {        $connection = $this->_adapter->getConnection();        if (!$this->_stmt) {            return false;        }        if (! $this->_stmt) {            /**             * @see Zend_Db_Adapter_Oracle_Exception             */            require_once 'Zend/Db/Statement/Oracle/Exception.php';            throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection));        }        if ($params !== null) {            if (!is_array($params)) {                $params = array($params);            }            $error = false;            foreach (array_keys($params) as $name) {                if (!@oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) {                    $error = true;                    break;                }            }            if ($error) {                /**                 * @see Zend_Db_Adapter_Oracle_Exception                 */                require_once 'Zend/Db/Statement/Oracle/Exception.php';                throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));            }        }        $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode());        if ($retval === false) {            /**             * @see Zend_Db_Adapter_Oracle_Exception             */            require_once 'Zend/Db/Statement/Oracle/Exception.php';            throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));        }        $this->_keys = Array();        if ($field_num = oci_num_fields($this->_stmt)) {            for ($i = 1; $i <= $field_num; $i++) {                $name = oci_field_name($this->_stmt, $i);                $this->_keys[] = $name;            }        }        $this->_values = Array();        if ($this->_keys) {            $this->_values = array_fill(0, count($this->_keys), null);        }        return $retval;    }    /**     * Fetches a row from the result set.     *     * @param int $style  OPTIONAL Fetch mode for this fetch operation.

⌨️ 快捷键说明

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