irm-1.6-b3/MDB/pgsql.php
/**
     * Connect to the database
     *
     * @return TRUE on success, MDB_Error on failure
     * @access public
     **/
Connect to the database
@return TRUE on success, MDB_Error on failure
@access public
Connect to the database @return TRUE on success MDB_Error on failure @access public
function connect()
    {
        $port = (isset($this->options['port']) ? $this->options['port'] : '');
        if($this->connection != 0) {
            if (!strcmp($this->connected_host, $this->host)
                && !strcmp($this->connected_port, $port)
                && !strcmp($this->selected_database, $this->database_name)
                && ($this->opened_persistent == $this->options['persistent']))
            {
                return(MDB_OK);
            }
            @pg_close($this->connection);
            $this->affected_rows = -1;
            $this->connection = 0;
        }
        if(!PEAR::loadExtension($this->phptype)) {
            return(PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND,
                NULL, NULL, 'extension '.$this->phptype.' is not compiled into PHP',
                'MDB_Error', TRUE));
        }
        if(function_exists('pg_cmdTuples')) {
            $connection = $this->_doConnect('template1', 0);
            if (!MDB::isError($connection)) {
                if (($result = @pg_exec($connection, 'BEGIN'))) {
                    $error_reporting = error_reporting(63);
                    @pg_cmdtuples($result);
                    if (!isset($php_errormsg) || strcmp($php_errormsg, 'This compilation does not support pg_cmdtuples()')) {
                        $this->supported['AffectedRows'] = 1;
                    }
                    error_reporting($error_reporting);
                } else {
                    $err = $this->raiseError(MDB_ERROR, NULL, NULL, 'Setup: '.@pg_errormessage($connection));
                }
                @pg_close($connection);
            } else {
                $err = $this->raiseError(MDB_ERROR, NULL, NULL, 'Setup: could not execute BEGIN');
            }
            if (isset($err) && MDB::isError($err)) {
                return($err);
            }
        }
        $connection = $this->_doConnect($this->database_name, $this->options['persistent']);
        if (MDB::isError($connection)) {
            return($connection);
        }
        $this->connection = $connection;
        if (!$this->auto_commit && MDB::isError($trans_result = $this->_doQuery('BEGIN'))) {
            pg_Close($this->connection);
            $this->connection = 0;
            $this->affected_rows = -1;
            return($trans_result);
        }
        $this->connected_host = $this->host;
        $this->connected_port = $port;
        $this->selected_database = $this->database_name;
        $this->opened_persistent = $this->options['persistent'];
        return(MDB_OK);
    }
function connect ( ) { $ port = ( isset ( $ this -> options [ 'port' ] ) ? $ this -> options [ 'port' ] : '' ) ; if ( $ this -> connection != 0 ) { if ( ! strcmp ( $ this -> connected_host , $ this -> host ) && ! strcmp ( $ this -> connected_port , $ port ) && ! strcmp ( $ this -> selected_database , $ this -> database_name ) && ( $ this -> opened_persistent == $ this -> options [ 'persistent' ] ) ) { return ( MDB_OK ) ; } @ pg_close ( $ this -> connection ) ; $ this -> affected_rows = - 1 ; $ this -> connection = 0 ; } if ( ! PEAR :: loadExtension ( $ this -> phptype ) ) { return ( PEAR :: raiseError ( NULL , MDB_ERROR_NOT_FOUND , NULL , NULL , 'extension ' . $ this -> phptype . ' is not compiled into PHP' , 'MDB_Error' , TRUE ) ) ; } if ( function_exists ( 'pg_cmdTuples' ) ) { $ connection = $ this -> _doConnect ( 'template1' , 0 ) ; if ( ! MDB :: isError ( $ connection ) ) { if ( ( $ result = @ pg_exec ( $ connection , 'BEGIN' ) ) ) { $ error_reporting = error_reporting ( 63 ) ; @ pg_cmdtuples ( $ result ) ; if ( ! isset ( $ php_errormsg ) || strcmp ( $ php_errormsg , 'This compilation does not support pg_cmdtuples()' ) ) { $ this -> supported [ 'AffectedRows' ] = 1 ; } error_reporting ( $ error_reporting ) ; } else { $ err = $ this -> raiseError ( MDB_ERROR , NULL , NULL , 'Setup: ' . @ pg_errormessage ( $ connection ) ) ; } @ pg_close ( $ connection ) ; } else { $ err = $ this -> raiseError ( MDB_ERROR , NULL , NULL , 'Setup: could not execute BEGIN' ) ; } if ( isset ( $ err ) && MDB :: isError ( $ err ) ) { return ( $ err ) ; } } $ connection = $ this -> _doConnect ( $ this -> database_name , $ this -> options [ 'persistent' ] ) ; if ( MDB :: isError ( $ connection ) ) { return ( $ connection ) ; } $ this -> connection = $ connection ; if ( ! $ this -> auto_commit && MDB :: isError ( $ trans_result = $ this -> _doQuery ( 'BEGIN' ) ) ) { pg_Close ( $ this -> connection ) ; $ this -> connection = 0 ; $ this -> affected_rows = - 1 ; return ( $ trans_result ) ; } $ this -> connected_host = $ this -> host ; $ this -> connected_port = $ port ; $ this -> selected_database = $ this -> database_name ; $ this -> opened_persistent = $ this -> options [ 'persistent' ] ; return ( MDB_OK ) ; }
Connect to the database
 @return TRUE on success, MDB_Error on failure
 @access public
Connect to the database @return TRUE on success MDB_Error on failure @access public