function DB_mysql::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
File
- phpFlickr/
PEAR/ DB/ mysql.php, line 371
Class
- DB_mysql
- The methods PEAR DB uses to interact with PHP's mysql extension for interacting with MySQL databases
Code
function fetchInto($result, &$arr, $fetchmode, $rownum = null) {
if ($rownum !== null) {
if (!@mysql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$arr = @mysql_fetch_array($result, MYSQL_ASSOC);
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
}
else {
$arr = @mysql_fetch_row($result);
}
if (!$arr) {
return null;
}
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
/*
* Even though this DBMS already trims output, we do this because
* a field might have intentional whitespace at the end that
* gets removed by DB_PORTABILITY_RTRIM under another driver.
*/
$this
->_rtrimArrayValues($arr);
}
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
$this
->_convertNullArrayValuesToEmpty($arr);
}
return DB_OK;
}