irm-1.6-b3/MDB/querysim.php
/**
     * 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
     *        be persistent (default FALSE) or assoc array of config options
     *
     * @access public
     *
     * @return mixed MDB_OK string on success, a MDB error object on failure
     */
Open a file or simulate a successful database connect
@param string $dsn the data source name
@param mixed $persistent (optional) boolean whether the connection should
be persistent (default FALSE) or assoc array of config options

@access public

@return mixed MDB_OK string on success, a MDB error object on failure
Open a file or simulate a successful database connect @param string $dsn the data source name @param mixed $persistent ( optional ) boolean whether the connection should be persistent ( default FALSE ) or assoc array of config options @access public @return mixed MDB_OK string on success a MDB error object on failure
function connect()
    {
        if($this->connection != 0) {
            if (!strcmp($this->selected_database, $this->database_name)
                && ($this->opened_persistent == $this->options['persistent']))
            {
                return MDB_OK;
            }
            if ($this->selected_database) {
                $this->_close($this->connection);
            }
            $this->connection = 0;
        }
        if(is_array($this->options)) {
            foreach($this->options as $option => $value) {
                if((in_array($option, array('columnDelim','dataDelim','eolDelim')))
                    && ($value == '\\')) {
                        return $this->raiseError(MDB_ERROR, null, null,
                            "MDB Error: option $option cannot be set to '\\'");
                }
            }
        }
        $connection = 1;
        if ($this->database_name) {
            $file = $this->database_name;
            if (!file_exists($file)) {
                return $this->raiseError(MDB_ERROR_NOT_FOUND, null, null, 'file not found');
            }
            if (!is_file($file)) {
                return $this->raiseError(MDB_ERROR_INVALID, null, null, 'not a file');
            }
            if (!is_readable($file)) {
                return $this->raiseError(MDB_ERROR_ACCESS_VIOLATION, null, null,
                    'could not open file - check permissions');
            }
            if ($this->options['persistent']) {
                $connection = @fopen($file, 'r');
            }
        }
        $this->connection = $connection;
        $this->selected_database = $this->database_name;
        $this->opened_persistent = $this->options['persistent'];
        return MDB_OK;
    }
function connect ( ) { if ( $ this -> connection != 0 ) { if ( ! strcmp ( $ this -> selected_database , $ this -> database_name ) && ( $ this -> opened_persistent == $ this -> options [ 'persistent' ] ) ) { return MDB_OK ; } if ( $ this -> selected_database ) { $ this -> _close ( $ this -> connection ) ; } $ this -> connection = 0 ; } if ( is_array ( $ this -> options ) ) { foreach ( $ this -> options as $ option => $ value ) { if ( ( in_array ( $ option , array ( 'columnDelim' , 'dataDelim' , 'eolDelim' ) ) ) && ( $ value == '\\' ) ) { return $ this -> raiseError ( MDB_ERROR , null , null , " MDB Error: option  $ option  cannot be set to ' \\ ' " ) ; } } } $ connection = 1 ; if ( $ this -> database_name ) { $ file = $ this -> database_name ; if ( ! file_exists ( $ file ) ) { return $ this -> raiseError ( MDB_ERROR_NOT_FOUND , null , null , 'file not found' ) ; } if ( ! is_file ( $ file ) ) { return $ this -> raiseError ( MDB_ERROR_INVALID , null , null , 'not a file' ) ; } if ( ! is_readable ( $ file ) ) { return $ this -> raiseError ( MDB_ERROR_ACCESS_VIOLATION , null , null , 'could not open file - check permissions' ) ; } if ( $ this -> options [ 'persistent' ] ) { $ connection = @ fopen ( $ file , 'r' ) ; } } $ this -> connection = $ connection ; $ this -> selected_database = $ this -> database_name ; $ this -> opened_persistent = $ this -> options [ 'persistent' ] ; return MDB_OK ; }
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
        be persistent (default FALSE) or assoc array of config options
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 be persistent ( default FALSE ) or assoc array of config options
// sim connect // if external, check file... // ...and open if persistent