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

📄 dbase.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: *//** * The PEAR DB driver for PHP's dbase extension * for interacting with dBase 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     Tomas V.V. Cox <cox@idecnet.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: dbase.php,v 1.39 2005/02/19 23:25:25 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 dbase extension * for interacting with dBase databases * * These methods overload the ones declared in DB_common. * * @category   Database * @package    DB * @author     Tomas V.V. Cox <cox@idecnet.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_dbase extends DB_common{    // {{{ properties    /**     * The DB driver type (mysql, oci8, odbc, etc.)     * @var string     */    var $phptype = 'dbase';    /**     * The database syntax variant to be used (db2, access, etc.), if any     * @var string     */    var $dbsyntax = 'dbase';    /**     * 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'         => false,        'new_link'      => false,        'numrows'       => true,        'pconnect'      => false,        'prepare'       => false,        'ssl'           => false,        'transactions'  => false,    );    /**     * A mapping of native error codes to DB error codes     * @var array     */    var $errorcode_map = array(    );    /**     * The raw database connection created by PHP     * @var resource     */    var $connection;    /**     * The DSN information for connecting to a database     * @var array     */    var $dsn = array();    /**     * A means of emulating result resources     * @var array     */    var $res_row = array();    /**     * The quantity of results so far     *     * For emulating result resources.     *     * @var integer     */    var $result = 0;    /**     * Maps dbase data type id's to human readable strings     *     * The human readable values are based on the output of PHP's     * dbase_get_header_info() function.     *     * @var array     * @since Property available since Release 1.7.0     */    var $types = array(        'C' => 'character',        'D' => 'date',        'L' => 'boolean',        'M' => 'memo',        'N' => 'number',    );    // }}}    // {{{ constructor    /**     * This constructor calls <kbd>$this->DB_common()</kbd>     *     * @return void     */    function DB_dbase()    {        $this->DB_common();    }    // }}}    // {{{ connect()    /**     * Connect to the database and create it if it doesn't exist     *     * Don't call this method directly.  Use DB::connect() instead.     *     * PEAR DB's dbase driver supports the following extra DSN options:     *   + mode    An integer specifying the read/write mode to use     *              (0 = read only, 1 = write only, 2 = read/write).     *              Available since PEAR DB 1.7.0.     *   + fields  An array of arrays that PHP's dbase_create() function needs     *              to create a new database.  This information is used if the     *              dBase file specified in the "database" segment of the DSN     *              does not exist.  For more info, see the PHP manual's     *              {@link http://php.net/dbase_create dbase_create()} page.     *              Available since PEAR DB 1.7.0.     *     * Example of how to connect and establish a new dBase file if necessary:     * <code>     * require_once 'DB.php';     *     * $dsn = array(     *     'phptype'  => 'dbase',     *     'database' => '/path/and/name/of/dbase/file',     *     'mode'     => 2,     *     'fields'   => array(     *         array('a', 'N', 5, 0),     *         array('b', 'C', 40),     *         array('c', 'C', 255),     *         array('d', 'C', 20),     *     ),     * );     * $options = array(     *     'debug'       => 2,     *     'portability' => DB_PORTABILITY_ALL,     * );     *     * $db =& DB::connect($dsn, $options);     * if (PEAR::isError($db)) {     *     die($db->getMessage());     * }     * </code>     *     * @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('dbase')) {            return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);        }        $this->dsn = $dsn;        if ($dsn['dbsyntax']) {            $this->dbsyntax = $dsn['dbsyntax'];        }        /*         * Turn track_errors on for entire script since $php_errormsg         * is the only way to find errors from the dbase extension.         */        ini_set('track_errors', 1);        $php_errormsg = '';        if (!file_exists($dsn['database'])) {            $this->dsn['mode'] = 2;            if (empty($dsn['fields']) || !is_array($dsn['fields'])) {                return $this->raiseError(DB_ERROR_CONNECT_FAILED,                                         null, null, null,                                         'the dbase file does not exist and '                                         . 'it could not be created because '                                         . 'the "fields" element of the DSN '                                         . 'is not properly set');            }            $this->connection = @dbase_create($dsn['database'],                                              $dsn['fields']);            if (!$this->connection) {                return $this->raiseError(DB_ERROR_CONNECT_FAILED,                                         null, null, null,                                         'the dbase file does not exist and '                                         . 'the attempt to create it failed: '                                         . $php_errormsg);            }        } else {            if (!isset($this->dsn['mode'])) {                $this->dsn['mode'] = 0;            }            $this->connection = @dbase_open($dsn['database'],                                            $this->dsn['mode']);            if (!$this->connection) {                return $this->raiseError(DB_ERROR_CONNECT_FAILED,                                         null, null, null,                                         $php_errormsg);            }        }        return DB_OK;    }    // }}}    // {{{ disconnect()

⌨️ 快捷键说明

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