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

📄 ifx.php

📁 太烦了
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    function numRows($result)    {        return $this->raiseError(DB_ERROR_NOT_CAPABLE);    }    // }}}    // {{{ numCols()    /**     * Get the number of columns in a result set.     *     * @param $result Informix result identifier     *     * @return int the number of columns per row in $result     */    function numCols($result)    {        if (!$cols = @ifx_num_fields($result)) {            return $this->ifxraiseError();        }        return $cols;    }    // }}}    // {{{ freeResult()    /**     * Free the internal resources associated with $result.     *     * @param $result Informix result identifier     *     * @return bool true on success, false if $result is invalid     */    function freeResult($result)    {        return @ifx_free_result($result);    }    // }}}    // {{{ autoCommit()    /**     * Enable/disable automatic commits     */    function autoCommit($onoff = true)    {        // XXX if $this->transaction_opcount > 0, we should probably        // issue a warning here.        $this->autocommit = $onoff ? true : false;        return DB_OK;    }    // }}}    // {{{ commit()    /**     * Commit the current transaction.     */    function commit()    {        if ($this->transaction_opcount > 0) {            $result = @ifx_query('COMMIT WORK', $this->connection);            $this->transaction_opcount = 0;            if (!$result) {                return $this->ifxRaiseError();            }        }        return DB_OK;    }    // }}}    // {{{ rollback()    /**     * Roll back (undo) the current transaction.     */    function rollback()    {        if ($this->transaction_opcount > 0) {            $result = @ifx_query('ROLLBACK WORK', $this->connection);            $this->transaction_opcount = 0;            if (!$result) {                return $this->ifxRaiseError();            }        }        return DB_OK;    }    // }}}    // {{{ ifxraiseError()    /**     * Gather information about an error, then use that info to create a     * DB error object and finally return that object.     *     * @param  integer  $errno  PEAR error number (usually a DB constant) if     *                          manually raising an error     * @return object  DB error object     * @see errorNative()     * @see errorCode()     * @see DB_common::raiseError()     */    function ifxraiseError($errno = null)    {        if ($errno === null) {            $errno = $this->errorCode(ifx_error());        }        return $this->raiseError($errno, null, null, null,                            $this->errorNative());    }    // }}}    // {{{ errorCode()    /**     * Map native error codes to DB's portable ones.     *     * Requires that the DB implementation's constructor fills     * in the <var>$errorcode_map</var> property.     *     * @param  string  $nativecode  error code returned by the database     * @return int a portable DB error code, or DB_ERROR if this DB     * implementation has no mapping for the given error code.     */    function errorCode($nativecode)    {        if (ereg('SQLCODE=(.*)]', $nativecode, $match)) {            $code = $match[1];            if (isset($this->errorcode_map[$code])) {                return $this->errorcode_map[$code];            }        }        return DB_ERROR;    }    // }}}    // {{{ errorNative()    /**     * Get the native error message of the last error (if any) that     * occured on the current connection.     *     * @return int native Informix error code     */    function errorNative()    {        return @ifx_error() . ' ' . @ifx_errormsg();    }    // }}}    // {{{ getSpecialQuery()    /**     * Returns the query needed to get some backend info     * @param string $type What kind of info you want to retrieve     * @return string The SQL query string     */    function getSpecialQuery($type)    {        switch ($type) {            case 'tables':                return 'select tabname from systables where tabid >= 100';            default:                return null;        }    }    // }}}    // {{{ tableInfo()    /**     * Returns information about a table or a result set.     *     * NOTE: only supports 'table' if <var>$result</var> is a table name.     *     * If analyzing a query result and the result has duplicate field names,     * an error will be raised saying     * <samp>can't distinguish duplicate field names</samp>.     *     * @param object|string  $result  DB_result object from a query or a     *                                string containing the name of a table     * @param int            $mode    a valid tableInfo mode     * @return array  an associative array with the information requested     *                or an error object if something is wrong     * @access public     * @internal     * @since 1.6.0     * @see DB_common::tableInfo()     */    function tableInfo($result, $mode = null)    {        if (isset($result->result)) {            /*             * Probably received a result object.             * Extract the result resource identifier.             */            $id = $result->result;            $got_string = false;        } elseif (is_string($result)) {            /*             * Probably received a table name.             * Create a result resource identifier.             */            $id = @ifx_query("SELECT * FROM $result WHERE 1=0",                             $this->connection);            $got_string = true;        } else {            /*             * Probably received a result resource identifier.             * Copy it.             */            $id = $result;            $got_string = false;        }        if (!is_resource($id)) {            return $this->ifxRaiseError(DB_ERROR_NEED_MORE_DATA);        }        $flds = @ifx_fieldproperties($id);        $count = @ifx_num_fields($id);        if (count($flds) != $count) {            return $this->raiseError("can't distinguish duplicate field names");        }        if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {            $case_func = 'strtolower';        } else {            $case_func = 'strval';        }        $i = 0;        // made this IF due to performance (one if is faster than $count if's)        if (!$mode) {            foreach ($flds as $key => $value) {                $props = explode(';', $value);                $res[$i]['table'] = $got_string ? $case_func($result) : '';                $res[$i]['name']  = $case_func($key);                $res[$i]['type']  = $props[0];                $res[$i]['len']   = $props[1];                $res[$i]['flags'] = $props[4] == 'N' ? 'not_null' : '';                $i++;            }        } else { // full            $res['num_fields'] = $count;            foreach ($flds as $key => $value) {                $props = explode(';', $value);                $res[$i]['table'] = $got_string ? $case_func($result) : '';                $res[$i]['name']  = $case_func($key);                $res[$i]['type']  = $props[0];                $res[$i]['len']   = $props[1];                $res[$i]['flags'] = $props[4] == 'N' ? 'not_null' : '';                if ($mode & DB_TABLEINFO_ORDER) {                    $res['order'][$res[$i]['name']] = $i;                }                if ($mode & DB_TABLEINFO_ORDERTABLE) {                    $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;                }                $i++;            }        }        // free the result only if we were called on a table        if ($got_string) {            @ifx_free_result($id);        }        return $res;    }    // }}}}/* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: */?>

⌨️ 快捷键说明

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