function DB_result::fetchRow in Flickr API 5
Fetch a row of data and return it by reference into an array
The type of array returned can be controlled either by setting this method's <var>$fetchmode</var> parameter or by changing the default fetch mode setFetchMode() before calling this method.
There are two options for standardizing the information returned from databases, ensuring their values are consistent when changing DBMS's. These portability options can be turned on when creating a new DB object or by using setOption().
+ <var>DB_PORTABILITY_LOWERCASE</var> convert names of fields to lower case
+ <var>DB_PORTABILITY_RTRIM</var> right trim the data
Parameters
int $fetchmode the constant indicating how to format the data:
int $rownum the row number to fetch (index starts at 0):
Return value
mixed an array or object containing the row's data, NULL when the end of the result set is reached or a DB_Error object on failure.
See also
DB_common::setOption(), DB_common::setFetchMode()
File
- phpFlickr/
PEAR/ DB.php, line 1082
Class
- DB_result
- This class implements a wrapper for a DB result set
Code
function &fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) {
if ($fetchmode === DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
if ($fetchmode === DB_FETCHMODE_OBJECT) {
$fetchmode = DB_FETCHMODE_ASSOC;
$object_class = $this->fetchmode_object_class;
}
if ($this->limit_from !== null) {
if ($this->row_counter === null) {
$this->row_counter = $this->limit_from;
// Skip rows
if ($this->dbh->features['limit'] === false) {
$i = 0;
while ($i++ < $this->limit_from) {
$this->dbh
->fetchInto($this->result, $arr, $fetchmode);
}
}
}
if ($this->row_counter >= $this->limit_from + $this->limit_count) {
if ($this->autofree) {
$this
->free();
}
$tmp = null;
return $tmp;
}
if ($this->dbh->features['limit'] === 'emulate') {
$rownum = $this->row_counter;
}
$this->row_counter++;
}
$res = $this->dbh
->fetchInto($this->result, $arr, $fetchmode, $rownum);
if ($res === DB_OK) {
if (isset($object_class)) {
// The default mode is specified in the
// DB_common::fetchmode_object_class property
if ($object_class == 'stdClass') {
$arr = (object) $arr;
}
else {
$arr =& new $object_class($arr);
}
}
return $arr;
}
if ($res == null && $this->autofree) {
$this
->free();
}
return $res;
}