You are here

function DB_pgsql::fetchInto in Flickr API 5

Places a row from the result set into the given array

Formating of the array and the data therein are configurable. See DB_result::fetchInto() for more information.

This method is not meant to be called directly. Use DB_result::fetchInto() instead. It can't be declared "protected" because DB_result is a separate object.

Parameters

resource $result the query result resource:

array $arr the referenced array to put the data in:

int $fetchmode how the resulting array should be indexed:

int $rownum the row number to fetch (0 = first row):

Return value

mixed DB_OK on success, NULL when the end of a result set is reached or on failure

See also

DB_result::fetchInto()

File

phpFlickr/PEAR/DB/pgsql.php, line 405

Class

DB_pgsql
The methods PEAR DB uses to interact with PHP's pgsql extension for interacting with PostgreSQL databases

Code

function fetchInto($result, &$arr, $fetchmode, $rownum = null) {
  $result_int = (int) $result;
  $rownum = $rownum !== null ? $rownum : $this->row[$result_int];
  if ($rownum >= $this->_num_rows[$result_int]) {
    return null;
  }
  if ($fetchmode & DB_FETCHMODE_ASSOC) {
    $arr = @pg_fetch_array($result, $rownum, PGSQL_ASSOC);
    if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
      $arr = array_change_key_case($arr, CASE_LOWER);
    }
  }
  else {
    $arr = @pg_fetch_row($result, $rownum);
  }
  if (!$arr) {
    return null;
  }
  if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
    $this
      ->_rtrimArrayValues($arr);
  }
  if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
    $this
      ->_convertNullArrayValuesToEmpty($arr);
  }
  $this->row[$result_int] = ++$rownum;
  return DB_OK;
}