irm-1.6-b3/MDB/pgsql.php
/**
     * Send a query to the database and return any results
     *
     * @param string $query the SQL query
     * @param array $types array that contains the types of the columns in
     *                         the result set
     * @return mixed result identifier if query executed, else MDB_error
     * @access public
     **/
Send a query to the database and return any results
@param string $query the SQL query
@param array $types array that contains the types of the columns in
the result set
@return mixed result identifier if query executed, else MDB_error
@access public
Send a query to the database and return any results @param string $query the SQL query @param array $types array that contains the types of the columns in the result set @return mixed result identifier if query executed else MDB_error @access public
function query($query, $types = NULL)
    {
        $this->debug("Query: $query");
        $ismanip = MDB::isManip($query);
        $this->last_query = $query;
        $first = $this->first_selected_row;
        $limit = $this->selected_row_limit;
        $this->first_selected_row = $this->selected_row_limit = 0;
        $connected = $this->connect();
        if (MDB::isError($connected)) {
            return($connected);
        }
        if (!$ismanip && $limit > 0) {
             if ($this->auto_commit && MDB::isError($this->_doQuery('BEGIN'))) {
                 return($this->raiseError(MDB_ERROR));
             }
             $result = $this->_doQuery('DECLARE select_cursor SCROLL CURSOR FOR '.$query);
             if (!MDB::isError($result)) {
                 if ($first > 0 && MDB::isError($result = $this->_doQuery("MOVE FORWARD $first FROM select_cursor"))) {
                     $this->freeResult($result);
                     return($result);
                 }
                 if (MDB::isError($result = $this->_doQuery("FETCH FORWARD $limit FROM select_cursor"))) {
                     $this->freeResult($result);
                     return($result);
                 }
             } else {
                 return($result);
             }
             if ($this->auto_commit && MDB::isError($result2 = $this->_doQuery('END'))) {
                 $this->freeResult($result);
                 return($result2);
             }
         } else {
            $result = $this->_doQuery($query);
            if (MDB::isError($result)) {
                return($result);
            }
        }
        if ($ismanip) {
            $this->affected_rows = @pg_cmdtuples($result);
            return(MDB_OK);
        } elseif ((preg_match('/^\s*\(?\s*SELECT\s+/si', $query)
                && !preg_match('/^\s*\(?\s*SELECT\s+INTO\s/si', $query)
            ) || preg_match('/^\s*EXPLAIN/si',$query )
        ) {
            $result_value = intval($result);
            $this->highest_fetched_row[$result_value] = -1;
            if ($types != NULL) {
                if (!is_array($types)) {
                    $types = array($types);
                }
                if (MDB::isError($err = $this->setResultTypes($result, $types))) {
                    $this->freeResult($result);
                    return($err);
                }
            }
            return($result);
        } else {
            $this->affected_rows = 0;
            return(MDB_OK);
        }
        return($this->raiseError(MDB_ERROR));
    }
function query ( $ query , $ types = NULL ) { $ this -> debug ( " Query:  $ query " ) ; $ ismanip = MDB :: isManip ( $ query ) ; $ this -> last_query = $ query ; $ first = $ this -> first_selected_row ; $ limit = $ this -> selected_row_limit ; $ this -> first_selected_row = $ this -> selected_row_limit = 0 ; $ connected = $ this -> connect ( ) ; if ( MDB :: isError ( $ connected ) ) { return ( $ connected ) ; } if ( ! $ ismanip && $ limit > 0 ) { if ( $ this -> auto_commit && MDB :: isError ( $ this -> _doQuery ( 'BEGIN' ) ) ) { return ( $ this -> raiseError ( MDB_ERROR ) ) ; } $ result = $ this -> _doQuery ( 'DECLARE select_cursor SCROLL CURSOR FOR ' . $ query ) ; if ( ! MDB :: isError ( $ result ) ) { if ( $ first > 0 && MDB :: isError ( $ result = $ this -> _doQuery ( " MOVE FORWARD  $ first  FROM select_cursor " ) ) ) { $ this -> freeResult ( $ result ) ; return ( $ result ) ; } if ( MDB :: isError ( $ result = $ this -> _doQuery ( " FETCH FORWARD  $ limit  FROM select_cursor " ) ) ) { $ this -> freeResult ( $ result ) ; return ( $ result ) ; } } else { return ( $ result ) ; } if ( $ this -> auto_commit && MDB :: isError ( $ result2 = $ this -> _doQuery ( 'END' ) ) ) { $ this -> freeResult ( $ result ) ; return ( $ result2 ) ; } } else { $ result = $ this -> _doQuery ( $ query ) ; if ( MDB :: isError ( $ result ) ) { return ( $ result ) ; } } if ( $ ismanip ) { $ this -> affected_rows = @ pg_cmdtuples ( $ result ) ; return ( MDB_OK ) ; } elseif ( ( preg_match ( '/^\s*\(?\s*SELECT\s+/si' , $ query ) && ! preg_match ( '/^\s*\(?\s*SELECT\s+INTO\s/si' , $ query ) ) || preg_match ( '/^\s*EXPLAIN/si' , $ query ) ) { $ result_value = intval ( $ result ) ; $ this -> highest_fetched_row [ $ result_value ] = - 1 ; if ( $ types != NULL ) { if ( ! is_array ( $ types ) ) { $ types = array ( $ types ) ; } if ( MDB :: isError ( $ err = $ this -> setResultTypes ( $ result , $ types ) ) ) { $ this -> freeResult ( $ result ) ; return ( $ err ) ; } } return ( $ result ) ; } else { $ this -> affected_rows = 0 ; return ( MDB_OK ) ; } return ( $ this -> raiseError ( MDB_ERROR ) ) ; }
Send a query to the database and return any results
 @param string $query the SQL query
 @param array $types array that contains the types of the columns in
                         the result set
 @return mixed result identifier if query executed, else MDB_error
 @access public
Send a query to the database and return any results @param string $query the SQL query @param array $types array that contains the types of the columns in the result set @return mixed result identifier if query executed else MDB_error @access public
/* PostgreSQL commands:
               ABORT, ALTER, BEGIN, CLOSE, CLUSTER, COMMIT, COPY,
               CREATE, DECLARE, DELETE, DROP TABLE, EXPLAIN, FETCH,
               GRANT, INSERT, LISTEN, LOAD, LOCK, MOVE, NOTIFY, RESET,
               REVOKE, ROLLBACK, SELECT, SELECT INTO, SET, SHOW,
               UNLISTEN, UPDATE, VACUUM
            */