irm-1.6-b3/MDB/ibase.php
/**
     * Fetch a row and return data in an array.
     *
     * @param resource $result result identifier
     * @param int $fetchmode how the array data should be indexed
     * @param int $rownum the row number to fetch
     * @return mixed data array or NULL on success, a MDB error on failure
     * @access public
     */
Fetch a row and return data in an array.
Fetch a row and return data in an array .
function fetchInto($result, $fetchmode=MDB_FETCHMODE_DEFAULT, $rownum=null)
    {
        $result_value = intval($result);
        if (!isset($this->current_row[$result_value])) {
            return($this->raiseError(MDB_ERROR, NULL, NULL,
                'fetchInto: attemped to fetch on an unknown query result'));
        }
        if ($fetchmode == MDB_FETCHMODE_DEFAULT) {
            $fetchmode = $this->fetchmode;
        }
        if (is_null($rownum)) {
            $rownum = $this->current_row[$result_value] + 1;
        }
        if (!isset($this->results[$result_value][$rownum])
            && (!isset($this->results[$result_value][$this->highest_fetched_row[$result_value]])
                || $this->results[$result_value][$this->highest_fetched_row[$result_value]] !== false)
        ) {
            if (isset($this->limits[$result_value])) {
                if ($rownum > $this->limits[$result_value][1]) {
                                        if ($rownum == 0
                        || (isset($this->results[$result_value])
                            && count($this->results[$result_value]) == $rownum)
                    ) {
                        $this->highest_fetched_row[$result_value] = $rownum;
                        $this->current_row[$result_value] = $rownum;
                        $this->results[$result_value][$rownum] = false;
                    }
                    if ($this->options['autofree']) {
                        $this->freeResult($result);
                    }
                    return null;
                }
                if (MDB::isError($this->_skipLimitOffset($result))) {
                    $this->current_row[$result_value] = 0;
                    $this->results[$result_value] = array(false);
                    if ($this->options['autofree']) {
                        $this->freeResult($result);
                    }
                    return null;
                }
            }
            if (isset($this->row_buffer[$result_value])) {
                ++$this->current_row[$result_value];
                $this->results[$result_value][$this->current_row[$result_value]] =
                    $this->row_buffer[$result_value];
                unset($this->row_buffer[$result_value]);
            }
            if (!isset($this->results[$result_value][$rownum])
                && (!isset($this->results[$result_value][$this->highest_fetched_row[$result_value]])
                    || $this->results[$result_value][$this->highest_fetched_row[$result_value]] !== false)
            ) {
                while ($this->current_row[$result_value] < $rownum
                    && is_array($buffer = @ibase_fetch_row($result))
                ) {
                    ++$this->current_row[$result_value];
                    $this->results[$result_value][$this->current_row[$result_value]] = $buffer;
                }
                if ($this->current_row[$result_value] < $rownum) {
                    ++$this->current_row[$result_value];
                    $this->results[$result_value][$this->current_row[$result_value]] = false;
                }
            }
            $this->highest_fetched_row[$result_value] =
                max($this->highest_fetched_row[$result_value],
                    $this->current_row[$result_value]);
        } else {
            ++$this->current_row[$result_value];
        }
        if (isset($this->results[$result_value][$rownum])
            && $this->results[$result_value][$rownum]
        ) {
            $row = $this->results[$result_value][$rownum];
        } else {
            if ($this->options['autofree']) {
                $this->freeResult($result);
            }
            return null;
        }
        foreach ($row as $key => $value_with_space) {
            if (!is_null($value_with_space)) {
                $row[$key] = rtrim($value_with_space, ' ');
            }
        }
        if ($fetchmode & MDB_FETCHMODE_ASSOC) {
            $column_names = $this->getColumnNames($result);
            foreach ($column_names as $name => $i) {
                $column_names[$name] = $row[$i];
            }
            $row = $column_names;
        }
        if (isset($this->result_types[$result_value])) {
            $row = $this->convertResultRow($result, $row);
        }
        return $row;
    }
function fetchInto ( $ result , $ fetchmode = MDB_FETCHMODE_DEFAULT , $ rownum = null ) { $ result_value = intval ( $ result ) ; if ( ! isset ( $ this -> current_row [ $ result_value ] ) ) { return ( $ this -> raiseError ( MDB_ERROR , NULL , NULL , 'fetchInto: attemped to fetch on an unknown query result' ) ) ; } if ( $ fetchmode == MDB_FETCHMODE_DEFAULT ) { $ fetchmode = $ this -> fetchmode ; } if ( is_null ( $ rownum ) ) { $ rownum = $ this -> current_row [ $ result_value ] + 1 ; } if ( ! isset ( $ this -> results [ $ result_value ] [ $ rownum ] ) && ( ! isset ( $ this -> results [ $ result_value ] [ $ this -> highest_fetched_row [ $ result_value ] ] ) || $ this -> results [ $ result_value ] [ $ this -> highest_fetched_row [ $ result_value ] ] !== false ) ) { if ( isset ( $ this -> limits [ $ result_value ] ) ) { if ( $ rownum > $ this -> limits [ $ result_value ] [ 1 ] ) { if ( $ rownum == 0 || ( isset ( $ this -> results [ $ result_value ] ) && count ( $ this -> results [ $ result_value ] ) == $ rownum ) ) { $ this -> highest_fetched_row [ $ result_value ] = $ rownum ; $ this -> current_row [ $ result_value ] = $ rownum ; $ this -> results [ $ result_value ] [ $ rownum ] = false ; } if ( $ this -> options [ 'autofree' ] ) { $ this -> freeResult ( $ result ) ; } return null ; } if ( MDB :: isError ( $ this -> _skipLimitOffset ( $ result ) ) ) { $ this -> current_row [ $ result_value ] = 0 ; $ this -> results [ $ result_value ] = array ( false ) ; if ( $ this -> options [ 'autofree' ] ) { $ this -> freeResult ( $ result ) ; } return null ; } } if ( isset ( $ this -> row_buffer [ $ result_value ] ) ) { ++ $ this -> current_row [ $ result_value ] ; $ this -> results [ $ result_value ] [ $ this -> current_row [ $ result_value ] ] = $ this -> row_buffer [ $ result_value ] ; unset ( $ this -> row_buffer [ $ result_value ] ) ; } if ( ! isset ( $ this -> results [ $ result_value ] [ $ rownum ] ) && ( ! isset ( $ this -> results [ $ result_value ] [ $ this -> highest_fetched_row [ $ result_value ] ] ) || $ this -> results [ $ result_value ] [ $ this -> highest_fetched_row [ $ result_value ] ] !== false ) ) { while ( $ this -> current_row [ $ result_value ] < $ rownum && is_array ( $ buffer = @ ibase_fetch_row ( $ result ) ) ) { ++ $ this -> current_row [ $ result_value ] ; $ this -> results [ $ result_value ] [ $ this -> current_row [ $ result_value ] ] = $ buffer ; } if ( $ this -> current_row [ $ result_value ] < $ rownum ) { ++ $ this -> current_row [ $ result_value ] ; $ this -> results [ $ result_value ] [ $ this -> current_row [ $ result_value ] ] = false ; } } $ this -> highest_fetched_row [ $ result_value ] = max ( $ this -> highest_fetched_row [ $ result_value ] , $ this -> current_row [ $ result_value ] ) ; } else { ++ $ this -> current_row [ $ result_value ] ; } if ( isset ( $ this -> results [ $ result_value ] [ $ rownum ] ) && $ this -> results [ $ result_value ] [ $ rownum ] ) { $ row = $ this -> results [ $ result_value ] [ $ rownum ] ; } else { if ( $ this -> options [ 'autofree' ] ) { $ this -> freeResult ( $ result ) ; } return null ; } foreach ( $ row as $ key => $ value_with_space ) { if ( ! is_null ( $ value_with_space ) ) { $ row [ $ key ] = rtrim ( $ value_with_space , ' ' ) ; } } if ( $ fetchmode & MDB_FETCHMODE_ASSOC ) { $ column_names = $ this -> getColumnNames ( $ result ) ; foreach ( $ column_names as $ name => $ i ) { $ column_names [ $ name ] = $ row [ $ i ] ; } $ row = $ column_names ; } if ( isset ( $ this -> result_types [ $ result_value ] ) ) { $ row = $ this -> convertResultRow ( $ result , $ row ) ; } return $ row ; }
Fetch a row and return data in an array.
Fetch a row and return data in an array .
//upper limit // are all previous rows fetched so that we can set the end // of the result set and not have any "holes" in between?
 // offset skipping // end of result set reached