You are here

function DB_result::numRows in Flickr API 5

Get the number of rows in a result set

Return value

int the number of rows. A DB_Error object on failure.

File

phpFlickr/PEAR/DB.php, line 1238

Class

DB_result
This class implements a wrapper for a DB result set

Code

function numRows() {
  if ($this->dbh->features['numrows'] === 'emulate' && $this->dbh->options['portability'] & DB_PORTABILITY_NUMROWS) {
    if ($this->dbh->features['prepare']) {
      $res = $this->dbh
        ->query($this->query, $this->parameters);
    }
    else {
      $res = $this->dbh
        ->query($this->query);
    }
    if (DB::isError($res)) {
      return $res;
    }
    $i = 0;
    while ($res
      ->fetchInto($tmp, DB_FETCHMODE_ORDERED)) {
      $i++;
    }
    return $i;
  }
  else {
    return $this->dbh
      ->numRows($this->result);
  }
}