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

📄 oci8.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 3 页
字号:
    {        if ($rownum !== null) {            return $this->raiseError(DB_ERROR_NOT_CAPABLE);        }        if ($fetchmode & DB_FETCHMODE_ASSOC) {            $moredata = @OCIFetchInto($result,$arr,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS);            if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE &&                $moredata)            {                $arr = array_change_key_case($arr, CASE_LOWER);            }        } else {            $moredata = OCIFetchInto($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS);        }        if (!$moredata) {            return null;        }        if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {            $this->_rtrimArrayValues($arr);        }        if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {            $this->_convertNullArrayValuesToEmpty($arr);        }        return DB_OK;    }    // }}}    // {{{ freeResult()    /**     * Deletes the result set and frees the memory occupied by the result set     *     * This method is not meant to be called directly.  Use     * DB_result::free() instead.  It can't be declared "protected"     * because DB_result is a separate object.     *     * @param resource $result  PHP's query result resource     *     * @return bool  TRUE on success, FALSE if $result is invalid     *     * @see DB_result::free()     */    function freeResult($result)    {        return @OCIFreeStatement($result);    }    /**     * Frees the internal resources associated with a prepared query     *     * @param resource $stmt           the prepared statement's resource     * @param bool     $free_resource  should the PHP resource be freed too?     *                                  Use false if you need to get data     *                                  from the result set later.     *     * @return bool  TRUE on success, FALSE if $result is invalid     *     * @see DB_oci8::prepare()     */    function freePrepared($stmt, $free_resource = true)    {        if (!is_resource($stmt)) {            return false;        }        if ($free_resource) {            @ocifreestatement($stmt);        }        if (isset($this->prepare_types[(int)$stmt])) {            unset($this->prepare_types[(int)$stmt]);            unset($this->manip_query[(int)$stmt]);        } else {            return false;        }        return true;    }    // }}}    // {{{ numRows()    /**     * Gets the number of rows in a result set     *     * Only works if the DB_PORTABILITY_NUMROWS portability option     * is turned on.     *     * This method is not meant to be called directly.  Use     * DB_result::numRows() instead.  It can't be declared "protected"     * because DB_result is a separate object.     *     * @param resource $result  PHP's query result resource     *     * @return int  the number of rows.  A DB_Error object on failure.     *     * @see DB_result::numRows(), DB_common::setOption()     */    function numRows($result)    {        // emulate numRows for Oracle.  yuck.        if ($this->options['portability'] & DB_PORTABILITY_NUMROWS &&            $result === $this->last_stmt)        {            $countquery = 'SELECT COUNT(*) FROM ('.$this->last_query.')';            $save_query = $this->last_query;            $save_stmt = $this->last_stmt;            if (count($this->_data)) {                $smt = $this->prepare('SELECT COUNT(*) FROM ('.$this->last_query.')');                $count = $this->execute($smt, $this->_data);            } else {                $count =& $this->query($countquery);            }            if (DB::isError($count) ||                DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED)))            {                $this->last_query = $save_query;                $this->last_stmt = $save_stmt;                return $this->raiseError(DB_ERROR_NOT_CAPABLE);            }            return $row[0];        }        return $this->raiseError(DB_ERROR_NOT_CAPABLE);    }    // }}}    // {{{ numCols()    /**     * Gets the number of columns in a result set     *     * This method is not meant to be called directly.  Use     * DB_result::numCols() instead.  It can't be declared "protected"     * because DB_result is a separate object.     *     * @param resource $result  PHP's query result resource     *     * @return int  the number of columns.  A DB_Error object on failure.     *     * @see DB_result::numCols()     */    function numCols($result)    {        $cols = @OCINumCols($result);        if (!$cols) {            return $this->oci8RaiseError($result);        }        return $cols;    }    // }}}    // {{{ prepare()    /**     * Prepares a query for multiple execution with execute().     *     * With oci8, this is emulated.     *     * prepare() requires a generic query as string like <code>     *    INSERT INTO numbers VALUES (?, ?, ?)     * </code>.  The <kbd>?</kbd> characters are placeholders.     *     * Three types of placeholders can be used:     *   + <kbd>?</kbd>  a quoted scalar value, i.e. strings, integers     *   + <kbd>!</kbd>  value is inserted 'as is'     *   + <kbd>&</kbd>  requires a file name.  The file's contents get     *                     inserted into the query (i.e. saving binary     *                     data in a db)     *     * Use backslashes to escape placeholder characters if you don't want     * them to be interpreted as placeholders.  Example: <code>     *    "UPDATE foo SET col=? WHERE col='over \& under'"     * </code>     *     * @param string $query  the query to be prepared     *     * @return mixed  DB statement resource on success. DB_Error on failure.     *     * @see DB_oci8::execute()     */    function prepare($query)    {        $tokens   = preg_split('/((?<!\\\)[&?!])/', $query, -1,                               PREG_SPLIT_DELIM_CAPTURE);        $binds    = count($tokens) - 1;        $token    = 0;        $types    = array();        $newquery = '';        foreach ($tokens as $key => $val) {            switch ($val) {                case '?':                    $types[$token++] = DB_PARAM_SCALAR;                    unset($tokens[$key]);                    break;                case '&':                    $types[$token++] = DB_PARAM_OPAQUE;                    unset($tokens[$key]);                    break;                case '!':                    $types[$token++] = DB_PARAM_MISC;                    unset($tokens[$key]);                    break;                default:                    $tokens[$key] = preg_replace('/\\\([&?!])/', "\\1", $val);                    if ($key != $binds) {                        $newquery .= $tokens[$key] . ':bind' . $token;                    } else {                        $newquery .= $tokens[$key];                    }            }        }        $this->last_query = $query;        $newquery = $this->modifyQuery($newquery);        if (!$stmt = @OCIParse($this->connection, $newquery)) {            return $this->oci8RaiseError();        }        $this->prepare_types[(int)$stmt] = $types;        $this->manip_query[(int)$stmt] = DB::isManip($query);        return $stmt;    }    // }}}    // {{{ execute()    /**     * Executes a DB statement prepared with prepare().     *     * 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 resource  $stmt  a DB statement resource returned from prepare()     * @param mixed  $data  array, string or numeric data to be used in     *                      execution of the statement.  Quantity of items     *                      passed must match quantity of placeholders in     *                      query:  meaning 1 for non-array items or the     *                      quantity of elements in the array.     *     * @return mixed  returns an oic8 result resource for successful SELECT     *                queries, DB_OK for other successful queries.     *                A DB error object is returned on failure.     *     * @see DB_oci8::prepare()     */    function &execute($stmt, $data = array())    {        $data = (array)$data;        $this->last_parameters = $data;        $this->_data = $data;        $types =& $this->prepare_types[(int)$stmt];        if (count($types) != count($data)) {            $tmp =& $this->raiseError(DB_ERROR_MISMATCH);            return $tmp;        }        $i = 0;        foreach ($data as $key => $value) {            if ($types[$i] == DB_PARAM_MISC) {                /*                 * Oracle doesn't seem to have the ability to pass a                 * parameter along unchanged, so strip off quotes from start                 * and end, plus turn two single quotes to one single quote,                 * in order to avoid the quotes getting escaped by                 * Oracle and ending up in the database.                 */                $data[$key] = preg_replace("/^'(.*)'$/", "\\1", $data[$key]);                $data[$key] = str_replace("''", "'", $data[$key]);            } elseif ($types[$i] == DB_PARAM_OPAQUE) {                $fp = @fopen($data[$key], 'rb');                if (!$fp) {                    $tmp =& $this->raiseError(DB_ERROR_ACCESS_VIOLATION);                    return $tmp;                }                $data[$key] = fread($fp, filesize($data[$key]));                fclose($fp);            }            if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {                $tmp = $this->oci8RaiseError($stmt);                return $tmp;            }            $i++;        }        if ($this->autocommit) {            $success = @OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);        } else {            $success = @OCIExecute($stmt, OCI_DEFAULT);        }        if (!$success) {            $tmp = $this->oci8RaiseError($stmt);            return $tmp;        }        $this->last_stmt = $stmt;        if ($this->manip_query[(int)$stmt]) {            $tmp = DB_OK;        } else {            @ocisetprefetch($stmt, $this->options['result_buffering']);            $tmp =& new DB_result($this, $stmt);        }        return $tmp;    }    // }}}    // {{{ autoCommit()    /**     * Enables or disables automatic commits     *     * @param bool $onoff  true turns it on, false turns it off     *     * @return int  DB_OK on success.  A DB_Error object if the driver     *               doesn't support auto-committing transactions.     */    function autoCommit($onoff = false)    {        $this->autocommit = (bool)$onoff;;        return DB_OK;    }    // }}}    // {{{ commit()    /**     * Commits the current transaction     *     * @return int  DB_OK on success.  A DB_Error object on failure.     */    function commit()    {        $result = @OCICommit($this->connection);        if (!$result) {            return $this->oci8RaiseError();        }        return DB_OK;    }    // }}}    // {{{ rollback()    /**     * Reverts the current transaction     *     * @return int  DB_OK on success.  A DB_Error object on failure.     */    function rollback()    {        $result = @OCIRollback($this->connection);        if (!$result) {            return $this->oci8RaiseError();        }        return DB_OK;    }    // }}}    // {{{ affectedRows()    /**     * Determines the number of rows affected by a data maniuplation query     *     * 0 is returned for queries that don't manipulate data.     *     * @return int  the number of rows.  A DB_Error object on failure.     */    function affectedRows()    {        if ($this->last_stmt === false) {            return $this->oci8RaiseError();        }        $result = @OCIRowCount($this->last_stmt);        if ($result === false) {            return $this->oci8RaiseError($this->last_stmt);        }

⌨️ 快捷键说明

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