mdb2.php

来自「This is the script which used on 10minut」· PHP 代码 · 共 1,925 行 · 第 1/5 页

PHP
1,925
字号
        'field_case' => CASE_LOWER,
        'disable_query' => false,
        'result_class' => 'MDB2_Result_%s',
        'buffered_result_class' => 'MDB2_BufferedResult_%s',
        'result_wrap_class' => false,
        'result_buffering' => true,
        'fetch_class' => 'stdClass',
        'persistent' => false,
        'debug' => 0,
        'debug_handler' => 'MDB2_defaultDebugOutput',
        'debug_expanded_output' => false,
        'default_text_field_length' => 4096,
        'lob_buffer_length' => 8192,
        'log_line_break' => "\n",
        'idxname_format' => '%s_idx',
        'seqname_format' => '%s_seq',
        'savepoint_format' => 'MDB2_SAVEPOINT_%s',
        'statement_format' => 'MDB2_STATEMENT_%1$s_%2$s',
        'seqcol_name' => 'sequence',
        'quote_identifier' => false,
        'use_transactions' => true,
        'decimal_places' => 2,
        'portability' => MDB2_PORTABILITY_ALL,
        'modules' => array(
            'ex' => 'Extended',
            'dt' => 'Datatype',
            'mg' => 'Manager',
            'rv' => 'Reverse',
            'na' => 'Native',
            'fc' => 'Function',
        ),
        'emulate_prepared' => false,
        'datatype_map' => array(),
        'datatype_map_callback' => array(),
        'nativetype_map_callback' => array(),
        'lob_allow_url_include' => false,
        'bindname_format' => '(?:\d+)|(?:[a-zA-Z][a-zA-Z0-9_]*)',
    );

    /**
     * string array
     * @var     string
     * @access  protected
     */
    var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => false, 'escape_pattern' => false);

    /**
     * identifier quoting
     * @var     array
     * @access  protected
     */
    var $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"');

    /**
     * sql comments
     * @var     array
     * @access  protected
     */
    var $sql_comments = array(
        array('start' => '--', 'end' => "\n", 'escape' => false),
        array('start' => '/*', 'end' => '*/', 'escape' => false),
    );

    /**
     * comparision wildcards
     * @var     array
     * @access  protected
     */
    var $wildcards = array('%', '_');

    /**
     * column alias keyword
     * @var     string
     * @access  protected
     */
    var $as_keyword = ' AS ';

    /**
     * warnings
     * @var     array
     * @access  protected
     */
    var $warnings = array();

    /**
     * string with the debugging information
     * @var     string
     * @access  public
     */
    var $debug_output = '';

    /**
     * determine if there is an open transaction
     * @var     bool
     * @access  protected
     */
    var $in_transaction = false;

    /**
     * the smart transaction nesting depth
     * @var     int
     * @access  protected
     */
    var $nested_transaction_counter = null;

    /**
     * the first error that occured inside a nested transaction
     * @var     MDB2_Error|bool
     * @access  protected
     */
    var $has_transaction_error = false;

    /**
     * result offset used in the next query
     * @var     int
     * @access  protected
     */
    var $offset = 0;

    /**
     * result limit used in the next query
     * @var     int
     * @access  protected
     */
    var $limit = 0;

    /**
     * Database backend used in PHP (mysql, odbc etc.)
     * @var     string
     * @access  public
     */
    var $phptype;

    /**
     * Database used with regards to SQL syntax etc.
     * @var     string
     * @access  public
     */
    var $dbsyntax;

    /**
     * the last query sent to the driver
     * @var     string
     * @access  public
     */
    var $last_query;

    /**
     * the default fetchmode used
     * @var     int
     * @access  protected
     */
    var $fetchmode = MDB2_FETCHMODE_ORDERED;

    /**
     * array of module instances
     * @var     array
     * @access  protected
     */
    var $modules = array();

    /**
     * determines of the PHP4 destructor emulation has been enabled yet
     * @var     array
     * @access  protected
     */
    var $destructor_registered = true;

    // }}}
    // {{{ constructor: function __construct()

    /**
     * Constructor
     */
    function __construct()
    {
        end($GLOBALS['_MDB2_databases']);
        $db_index = key($GLOBALS['_MDB2_databases']) + 1;
        $GLOBALS['_MDB2_databases'][$db_index] = &$this;
        $this->db_index = $db_index;
    }

    // }}}
    // {{{ function MDB2_Driver_Common()

    /**
     * PHP 4 Constructor
     */
    function MDB2_Driver_Common()
    {
        $this->destructor_registered = false;
        $this->__construct();
    }

    // }}}
    // {{{ destructor: function __destruct()

    /**
     *  Destructor
     */
    function __destruct()
    {
        $this->disconnect(false);
    }

    // }}}
    // {{{ function free()

    /**
     * Free the internal references so that the instance can be destroyed
     *
     * @return  bool    true on success, false if result is invalid
     *
     * @access  public
     */
    function free()
    {
        unset($GLOBALS['_MDB2_databases'][$this->db_index]);
        unset($this->db_index);
        return MDB2_OK;
    }

    // }}}
    // {{{ function __toString()

    /**
     * String conversation
     *
     * @return  string representation of the object
     *
     * @access  public
     */
    function __toString()
    {
        $info = get_class($this);
        $info.= ': (phptype = '.$this->phptype.', dbsyntax = '.$this->dbsyntax.')';
        if ($this->connection) {
            $info.= ' [connected]';
        }
        return $info;
    }

    // }}}
    // {{{ function errorInfo($error = null)

    /**
     * This method is used to collect information about an error
     *
     * @param   mixed   error code or resource
     *
     * @return  array   with MDB2 errorcode, native error code, native message
     *
     * @access  public
     */
    function errorInfo($error = null)
    {
        return array($error, null, null);
    }

    // }}}
    // {{{ function &raiseError($code = null, $mode = null, $options = null, $userinfo = null)

    /**
     * This method is used to communicate an error and invoke error
     * callbacks etc.  Basically a wrapper for PEAR::raiseError
     * without the message string.
     *
     * @param   mixed   integer error code, or a PEAR error object (all other
     *                  parameters are ignored if this parameter is an object
     * @param   int     error mode, see PEAR_Error docs
     * @param   mixed   If error mode is PEAR_ERROR_TRIGGER, this is the
         *              error level (E_USER_NOTICE etc).  If error mode is
     *                  PEAR_ERROR_CALLBACK, this is the callback function,
     *                  either as a function name, or as an array of an
     *                  object and method name.  For other error modes this
     *                  parameter is ignored.
     * @param   string  Extra debug information.  Defaults to the last
     *                  query and native error code.
     * @param   string  name of the method that triggered the error
     *
     * @return PEAR_Error   instance of a PEAR Error object
     *
     * @access  public
     * @see     PEAR_Error
     */
    function &raiseError($code = null, $mode = null, $options = null, $userinfo = null, $method = null)
    {
        $userinfo = "[Error message: $userinfo]\n";
        // The error is yet a MDB2 error object
        if (PEAR::isError($code)) {
            // because we use the static PEAR::raiseError, our global
            // handler should be used if it is set
            if (is_null($mode) && !empty($this->_default_error_mode)) {
                $mode    = $this->_default_error_mode;
                $options = $this->_default_error_options;
            }
            if (is_null($userinfo)) {
                $userinfo = $code->getUserinfo();
            }
            $code = $code->getCode();
        } elseif ($code == MDB2_ERROR_NOT_FOUND) {
            // extension not loaded: don't call $this->errorInfo() or the script
            // will die
        } elseif (isset($this->connection)) {
            if (!empty($this->last_query)) {
                $userinfo.= "[Last executed query: {$this->last_query}]\n";
            }
            $native_errno = $native_msg = null;
            list($code, $native_errno, $native_msg) = $this->errorInfo($code);
            if (!is_null($native_errno) && $native_errno !== '') {
                $userinfo.= "[Native code: $native_errno]\n";
            }
            if (!is_null($native_msg) && $native_msg !== '') {
                $userinfo.= "[Native message: ". strip_tags($native_msg) ."]\n";
            }
            if (!is_null($method)) {
                $userinfo = $method.': '.$userinfo;
            }
        }

        $err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
        if ($err->getMode() !== PEAR_ERROR_RETURN
            && isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
            $this->has_transaction_error =& $err;
        }
        return $err;
    }

    // }}}
    // {{{ function resetWarnings()

    /**
     * reset the warning array
     *
     * @return void
     *
     * @access  public
     */
    function resetWarnings()
    {
        $this->warnings = array();
    }

    // }}}
    // {{{ function getWarnings()

    /**
     * Get all warnings in reverse order.
     * This means that the last warning is the first element in the array
     *
     * @return  array   with warnings
     *
     * @access  public
     * @see     resetWarnings()
     */
    function getWarnings()
    {
        return array_reverse($this->warnings);
    }

    // }}}
    // {{{ function setFetchMode($fetchmode, $object_class = 'stdClass')

    /**
     * Sets which fetch mode should be used by default on queries
     * on this connection
     *
     * @param   int     MDB2_FETCHMODE_ORDERED, MDB2_FETCHMODE_ASSOC
     *                               or MDB2_FETCHMODE_OBJECT
     * @param   string  the class name of the object to be returned
     *                               by the fetch methods when the
     *                               MDB2_FETCHMODE_OBJECT mode is selected.
     *                               If no class is specified by default a cast
     *                               to object from the assoc array row will be
     *                               done.  There is also the possibility to use
     *                               and extend the 'MDB2_row' class.
     *
     * @return  mixed   MDB2_OK or MDB2 Error Object
     *
     * @access  public
     * @see     MDB2_FETCHMODE_ORDERED, MDB2_FETCHMODE_ASSOC, MDB2_FETCHMODE_OBJECT
     */
    function setFetchMode($fetchmode, $object_class = 'stdClass')
    {
        switch ($fetchmode) {

⌨️ 快捷键说明

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