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

📄 dbase.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    /**     * Disconnects from the database server     *     * @return bool  TRUE on success, FALSE on failure     */    function disconnect()    {        $ret = @dbase_close($this->connection);        $this->connection = null;        return $ret;    }    // }}}    // {{{ &query()    function &query($query = null)    {        // emulate result resources        $this->res_row[(int)$this->result] = 0;        $tmp =& new DB_result($this, $this->result++);        return $tmp;    }    // }}}    // {{{ 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)    {        if ($rownum === null) {            $rownum = $this->res_row[(int)$result]++;        }        if ($fetchmode & DB_FETCHMODE_ASSOC) {            $arr = @dbase_get_record_with_names($this->connection, $rownum);            if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {                $arr = array_change_key_case($arr, CASE_LOWER);            }        } else {            $arr = @dbase_get_record($this->connection, $rownum);        }        if (!$arr) {            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;    }    // }}}    // {{{ 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($foo)    {        return @dbase_numfields($this->connection);    }    // }}}    // {{{ numRows()    /**     * Gets the number of rows in a result set     *     * 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()     */    function numRows($foo)    {        return @dbase_numrecords($this->connection);    }    // }}}    // {{{ quoteSmart()    /**     * Formats input so it can be safely used in a query     *     * @param mixed $in  the data to be formatted     *     * @return mixed  the formatted data.  The format depends on the input's     *                 PHP type:     *                 + null = the string <samp>NULL</samp>     *                 + boolean = <samp>T</samp> if true or     *                   <samp>F</samp> if false.  Use the <kbd>Logical</kbd>     *                   data type.     *                 + integer or double = the unquoted number     *                 + other (including strings and numeric strings) =     *                   the data with single quotes escaped by preceeding     *                   single quotes then the whole string is encapsulated     *                   between single quotes     *     * @see DB_common::quoteSmart()     * @since Method available since Release 1.6.0     */    function quoteSmart($in)    {        if (is_int($in) || is_double($in)) {            return $in;        } elseif (is_bool($in)) {            return $in ? 'T' : 'F';        } elseif (is_null($in)) {            return 'NULL';        } else {            return "'" . $this->escapeSimple($in) . "'";        }    }    // }}}    // {{{ tableInfo()    /**     * Returns information about the current database     *     * @param mixed $result  THIS IS UNUSED IN DBASE.  The current database     *                       is examined regardless of what is provided here.     * @param int   $mode    a valid tableInfo mode     *     * @return array  an associative array with the information requested.     *                 A DB_Error object on failure.     *     * @see DB_common::tableInfo()     * @since Method available since Release 1.7.0     */    function tableInfo($result = null, $mode = null)    {        if (function_exists('dbase_get_header_info')) {            $id = @dbase_get_header_info($this->connection);            if (!$id && $php_errormsg) {                return $this->raiseError(DB_ERROR,                                         null, null, null,                                         $php_errormsg);            }        } else {            /*             * This segment for PHP 4 is loosely based on code by             * Hadi Rusiah <deegos@yahoo.com> in the comments on             * the dBase reference page in the PHP manual.             */            $db = @fopen($this->dsn['database'], 'r');            if (!$db) {                return $this->raiseError(DB_ERROR_CONNECT_FAILED,                                         null, null, null,                                         $php_errormsg);            }            $id = array();            $i  = 0;            $line = fread($db, 32);            while (!feof($db)) {                $line = fread($db, 32);                if (substr($line, 0, 1) == chr(13)) {                    break;                } else {                    $pos = strpos(substr($line, 0, 10), chr(0));                    $pos = ($pos == 0 ? 10 : $pos);                    $id[$i] = array(                        'name'   => substr($line, 0, $pos),                        'type'   => $this->types[substr($line, 11, 1)],                        'length' => ord(substr($line, 16, 1)),                        'precision' => ord(substr($line, 17, 1)),                    );                }                $i++;            }            fclose($db);        }        if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {            $case_func = 'strtolower';        } else {            $case_func = 'strval';        }        $res   = array();        $count = count($id);        if ($mode) {            $res['num_fields'] = $count;        }        for ($i = 0; $i < $count; $i++) {            $res[$i] = array(                'table' => $this->dsn['database'],                'name'  => $case_func($id[$i]['name']),                'type'  => $id[$i]['type'],                'len'   => $id[$i]['length'],                'flags' => ''            );            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;            }        }        return $res;    }    // }}}}/* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: */?>

⌨️ 快捷键说明

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