irm-1.6-b3/MDB/mssql.php
/**
     * Send a query to the database and return any results
     *
     * @access public
     *
     * @param string  $query  the SQL query
     * @param mixed   $types  array that contains the types of the columns in
     *                        the result set
     *
     * @return mixed a result handle or MDB_OK on success, a MDB error on failure
     */
Send a query to the database and return any results
@access public

@param string  $query  the SQL query
@param mixed   $types  array that contains the types of the columns in
the result set

@return mixed a result handle or MDB_OK on success, a MDB error on failure
Send a query to the database and return any results @access public @param string $query the SQL query @param mixed $types array that contains the types of the columns in the result set @return mixed a result handle or MDB_OK on success a MDB error on failure
function query($query, $types = NULL)
    {
        $this->debug("Query: $query");
        if ($this->database_name) {
            $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;
            $last_connection = $this->connection;
            $result = $this->connect();
            if (MDB::isError($result)) {
                return($result);
            }
            if($limit > 0) {
                $fetch = $first + $limit;
                if (!$ismanip) {
                    $query = str_replace('SELECT', "SELECT TOP $fetch", $query);
                }
            }
            if( $last_connection != $this->connection
                || !strcmp($this->selected_database, '')
                || strcmp($this->selected_database, $this->database_name))
            {
                if(!@mssql_select_db($this->database_name, $this->connection)) {
                    return($this->mssqlRaiseError());
                }
            }
            if ($result = $this->_doQuery($query)) {
                if ($ismanip) {
                    $this->affected_rows = @mssql_rows_affected($this->connection);
                    return(MDB_OK);
                } else {
                    $result_value = intval($result);
                    if($first > 0 || $limit > 0) {
                        $this->limits[$result_value] = array($first, $limit);
                    }
                    $this->highest_fetched_row[$result_value] = -1;
                    if ($types != NULL) {
                        if (!is_array($types)) {
                            $types = array($types);
                        }
                        $err = $this->setResultTypes($result, $types);
                        if (MDB::isError($err)) {
                            $this->freeResult($result);
                            return($err);
                        }
                    }
                    return($result);
                }
            }
        }
        return($this->mssqlRaiseError());
    }
function query ( $ query , $ types = NULL ) { $ this -> debug ( " Query:  $ query " ) ; if ( $ this -> database_name ) { $ 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 ; $ last_connection = $ this -> connection ; $ result = $ this -> connect ( ) ; if ( MDB :: isError ( $ result ) ) { return ( $ result ) ; } if ( $ limit > 0 ) { $ fetch = $ first + $ limit ; if ( ! $ ismanip ) { $ query = str_replace ( 'SELECT' , " SELECT TOP  $ fetch " , $ query ) ; } } if ( $ last_connection != $ this -> connection || ! strcmp ( $ this -> selected_database , '' ) || strcmp ( $ this -> selected_database , $ this -> database_name ) ) { if ( ! @ mssql_select_db ( $ this -> database_name , $ this -> connection ) ) { return ( $ this -> mssqlRaiseError ( ) ) ; } } if ( $ result = $ this -> _doQuery ( $ query ) ) { if ( $ ismanip ) { $ this -> affected_rows = @ mssql_rows_affected ( $ this -> connection ) ; return ( MDB_OK ) ; } else { $ result_value = intval ( $ result ) ; if ( $ first > 0 || $ limit > 0 ) { $ this -> limits [ $ result_value ] = array ( $ first , $ limit ) ; } $ this -> highest_fetched_row [ $ result_value ] = - 1 ; if ( $ types != NULL ) { if ( ! is_array ( $ types ) ) { $ types = array ( $ types ) ; } $ err = $ this -> setResultTypes ( $ result , $ types ) ; if ( MDB :: isError ( $ err ) ) { $ this -> freeResult ( $ result ) ; return ( $ err ) ; } } return ( $ result ) ; } } } return ( $ this -> mssqlRaiseError ( ) ) ; }
Send a query to the database and return any results
 @access public
Send a query to the database and return any results @access public