querysim.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 830 行 · 第 1/3 页

PHP
830
字号
<?php// +----------------------------------------------------------------------+// | PHP Version 4                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |// | Stig. S. Bakken, Lukas Smith                                         |// | All rights reserved.                                                 |// +----------------------------------------------------------------------+// | MDB is a merge of PEAR DB and Metabases that provides a unified DB   |// | API as well as database abstraction for PHP applications.            |// | This LICENSE is in the BSD license style.                            |// |                                                                      |// | Redistribution and use in source and binary forms, with or without   |// | modification, are permitted provided that the following conditions   |// | are met:                                                             |// |                                                                      |// | Redistributions of source code must retain the above copyright       |// | notice, this list of conditions and the following disclaimer.        |// |                                                                      |// | Redistributions in binary form must reproduce the above copyright    |// | notice, this list of conditions and the following disclaimer in the  |// | documentation and/or other materials provided with the distribution. |// |                                                                      |// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |// | Lukas Smith nor the names of his contributors may be used to endorse |// | or promote products derived from this software without specific prior|// | written permission.                                                  |// |                                                                      |// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|// |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |// | POSSIBILITY OF SUCH DAMAGE.                                          |// +----------------------------------------------------------------------+// | Original QuerySim Concept & ColdFusion Author: Hal Helms             |// | <hal.helms@teamallaire.com>                                          |// | Bert Dawson <bdawson@redbanner.com>                                  |// +----------------------------------------------------------------------+// | Original PHP Author: Alan Richmond <arichmond@bigfoot.com>           |// | David Huyck <b@bombusbee.com>                                        |// +----------------------------------------------------------------------+// | Special note concerning code documentation:                          |// | QuerySim was originally created for use during development of        |// | applications built using the Fusebox framework. (www.fusebox.org)    |// | Fusebox uses an XML style of documentation called Fusedoc. (Which    |// | is admittedly not well suited to documenting classes and functions.  |// | This short-coming is being addressed by the Fusebox community.) PEAR |// | uses a Javadoc style of documentation called PHPDoc. (www.phpdoc.de) |// | Since this class extension spans two groups of users, it is asked    |// | that the members of each respect the documentation standard of the   |// | other.  So it is a further requirement that both documentation       |// | standards be included and maintained. If assistance is required      |// | please contact Alan Richmond.                                        |// +----------------------------------------------------------------------+//// $Id: querysim.php,v 1.6.4.5 2004/02/26 11:51:15 lsmith Exp $///*<fusedoc fuse="querysim.php" language="PHP">    <responsibilities>        I take information and turn it into a recordset that can be accessed        through the PEAR MDB API.  Based on Hal Helms' QuerySim.cfm ColdFusion        custom tag available at halhelms.com.    </responsibilities>    <properties>        <property name="API" value="PEAR MDB" />        <property name="version" value="0.2.1" />        <property name="status" value="beta" />        <history author="Hal Helms" email="hal.helms@teamallaire.com" type="Create" />        <history author="Bert Dawson" email="bdawson@redbanner.com" type="Update">            Extensive revision that is backwardly compatible but eliminates the            need for a separate .sim file.        </history>        <history author="Alan Richmond" email="arichmond@bigfoot.com" type="Create" date="10-July-2002">            Rewrote in PHP as an extention to the PEAR DB API.            Functions supported:                connect, disconnect, query, fetchRow, fetchInto, freeResult,                numCols, numRows, getSpecialQuery            David Huyck (bombusbee.com) added ability to escape special                characters (i.e., delimiters) using a '\'.            Extended PEAR DB options[] for adding incoming parameters.  Added                options:  columnDelim, dataDelim, eolDelim        </history>        <history author="David Huyck" email="b@bombusbee.com" type="Update" date="19-July-2002">            Added the ability to set the QuerySim options at runtime.            Default options are:                'columnDelim' => ',',            // Commas split the column names                'dataDelim'   => '|',            // Pipes split the data fields                'eolDelim'    => chr(13).chr(10) // Carriage returns split the                                                 // lines of data            Affected functions are:                DB_querysim():          set the default options when the                                        constructor method is called                _parseQuerySim($query): altered the parsing of lines, column                                        names, and data fields                _empty2null:            altered the way this function is called                                        to simplify calling it        </history>        <history author="Alan Richmond" email="arichmond@bigfoot.com" type="Update" date="24-July-2002">            Added error catching for malformed QuerySim text.            Bug fix _empty2null():  altered version was returning unmodified                                    lineData.            Cleanup:                PEAR compliant formatting, finished PHPDocs and added 'out' to                Fusedoc 'io'.                Broke up _parseQuerySim() into _buildResult() and _parseOnDelim()                to containerize duplicate parse code.        </history>        <history author="David Huyck" email="b@bombusbee.com" type="Update" date="25-July-2002">            Edited the _buildResult() and _parseOnDelim() functions to improve            reliability of special character escaping.            Re-introduced a custom setOption() method to throw an error when a            person tries to set one of the delimiters to '\'.        </history>        <history author="Alan Richmond" email="arichmond@bigfoot.com" type="Update" date="27-July-2002">            Added '/' delimiter param to preg_quote() in _empty2null() and            _parseOnDelim() so '/' can be used as a delimiter.            Added error check for columnDelim == eolDelim or dataDelim == eolDelim.            Renamed some variables for consistancy.        </history>        <history author="Alan Richmond" email="arichmond@bigfoot.com" type="Update" date="30-July-2002">            Removed private function _empty2null().  Turns out preg_split()            deals with empty elemants by making them zero length strings, just            what they ended up being anyway.  This should speed things up a little.            Affected functions:                _parseOnDelim()     perform trim on line here, instead of in                                    _empty2null().                _buildResult()      remove call to _empty2null().                _empty2null()       removed function.        </history>        <history author="Alan Richmond" email="arichmond@bigfoot.com" type="Update" date="1-Jan-2003">            Ported to PEAR MDB.            Methods supported:                connect, query, getColumnNames, numCols, endOfResult, fetch,                numRows, freeResult, fetchInto, nextResult, setSelectedRowRange                (inherited).        </history>        <history            Removed array_change_key_case() work around for <4.2.0 in            getColumnNames(), found it already done in MDB/Common.php.        </history>        <history author="Alan Richmond" email="arichmond@bigfoot.com" type="Update" date="3-Feb-2003">            Changed default eolDelim to a *nix file eol, since we're trimming            the result anyway, it makes no difference for Windows.  Now only            Mac file eols should need to be set (and other kinds of chars).        </history>        <note author="Alan Richmond">            Got WAY too long.  See querysim_readme.txt for instructions and some            examples.            io section only documents elements of DB_result that DB_querysim uses,            adds or changes; see MDB and MDB_Common for more info.            io section uses some elements that are not Fusedoc 2.0 compliant:            object and resource.        </note>    </properties>    <io>        <in>            <file path="MDB/Common.php" action="require_once" />        </in>        <out>            <object name="MDB_querysim" extends="MDB_Common" instantiatedby="MDB::connect()">                <resource type="file" name="connection" oncondition="source is external file" scope="class" />                <string name="phptype" default="querysim" />                <string name="dbsyntax" default="querysim" />                <array name="supported" comments="most of these don't actually do anything, they are enabled to simulate the option being available if checked">                    <boolean name="Sequences" default="true" />                    <boolean name="Indexes" default="true" />                    <boolean name="AffectedRows" default="true" />                    <boolean name="Summaryfunctions" default="true" />                    <boolean name="OrderByText" default="true" />                    <boolean name="CurrId" default="true" />                    <boolean name="SelectRowRanges" default="true" comments="this one is functional" />                    <boolean name="LOBs" default="true" />                    <boolean name="Replace" default="true" />                    <boolean name="SubSelects" default="true" />                    <boolean name="Transactions" default="true" />                </array>                <string name="last_query" comments="last value passed in with query()" />                <array name="options" comments="these can be changed at run time">                    <string name="columnDelim" default="," />                    <string name="dataDelim" default="|" />                    <string name="eolDelim" default="chr(13).chr(10)" />                </array>            </object>            <array name="result" comments="the simulated record set returned by ::query()">                <array comments="columns">                    <string comments="column name" />                </array>                <array comments="data">                    <array comments="row">                        <string comments="data element" />                    </array>                </array>            </array>        </out>    </io></fusedoc>*/require_once 'MDB/Common.php';/** * MDB QuerySim driver * * @package MDB * @category Database * @author  Alan Richmond <arichmond@bigfoot.com> */class MDB_querysim extends MDB_Common{// Most of the class variables are taken from the corresponding Metabase driver.// Few are taken from the corresponding PEAR DB driver.// Some are MDB specific.    var $connection = 0;    var $connected_host;    var $connected_user;    var $connected_password;    var $connected_port;    var $opened_persistent = '';    var $escape_quotes = "\\";    var $decimal_factor = 1.0;    var $highest_fetched_row = array();    var $columns = array();    // }}}    // {{{ constructor    /**    * Constructor    */    function MDB_querysim()    {        $this->MDB_Common();        $this->phptype  = 'querysim';        $this->dbsyntax = 'querysim';                // Most of these are dummies to simulate availability if checked        $this->supported['Sequences'] = 1;        $this->supported['Indexes'] = 1;        $this->supported['AffectedRows'] = 1;        $this->supported['Summaryfunctions'] = 1;        $this->supported['OrderByText'] = 1;        $this->supported['CurrId'] = 1;        $this->supported['SelectRowRanges'] = 1;// this one is real        $this->supported['LOBs'] = 1;        $this->supported['Replace'] = 1;        $this->supported['SubSelects'] = 1;        $this->supported['Transactions'] = 1;                // init QuerySim options        $querySimOptions = array(            'columnDelim' => ',',            'dataDelim'   => '|',            'eolDelim'    => "\n"        );        // let runtime options overwrite defaults        $this->options = array_merge($querySimOptions, $this->options);    }    // }}}    // {{{ connect()    /**     * Open a file or simulate a successful database connect     *     * @param string $dsn the data source name (see MDB::parseDSN for syntax)     * @param mixed $persistent (optional) boolean whether the connection should

⌨️ 快捷键说明

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