Each of these functions fetch a result row from a result set or a file, and returns the data in various formats.
|
array i5_fetch_row ( |
resource result, int option ) |
|
array i5_fetch_array ( |
resource result, int option ) |
|
array i5_fetch_assoc ( |
resource result, int option ) |
|
object i5_fetch_object ( |
resource result, int option ) |
i5_fetch_xxxx functions move the pointer according to the specified option, read the data from the record set or file, and fill up the result array.
To change the current cursor position in the result set or file, use functions i5_seek or i5_data_seek,before to fetch the row.
Warning: i5_fetch_xxx() does not read blob fields. See i5_getblob function.
|
result |
Result set or Open file ID |
|
option |
Cursor movement option. |
Valid options are:
|
I5_READ_NEXT |
Read next record, or the record requested by a previous call to i5_seek() or i5_data_seek(). |
|
I5_READ_PREV |
Read previous record |
|
I5_READ_FIRST |
Read the first record |
|
I5_READ_LAST |
Read the last record |
|
I5_READ_SAME |
Read the current record. Cursor position is not moved. |
|
|
|
|
I5_READ_SEEK |
Read current record |
Any attempt to read out of file limits will return NULL and create an error I5_ERR_BEOF type.
Returns:
Function i5_Fetch_xxx() return an array or FALSE in case of error.
The format of array returned varies with the called function:
|
i5_fetch_row |
Get a result row as an enumerated array. |
|
I5_fetch_array |
Fetch a result row as an associative array, and numeric array. |
|
i5_fetch_assoc |
Fetch a result row as an associative array. |
|
i5_fetch_object |
Fetch a result row as an object. |
Error returned
|
I5_ERR_MEMALLOC |
3 |
Not enough memory |
|
I5_ERR_PHP_HDLDFT |
256 |
No default connection found. |
|
I5_ERR_PHP_OPTIONSTYPE |
259 |
The type of " I5_OPTIONS_ALIAS" option must be x and not x |
|
I5_ERR_PHP_OPTIONSNUMBER |
260 |
Option number -1 is unknown. |
|
I5_ERR_PHP_TYPEPARAM |
262 |
Type of element x in parameter -1 must be y. Type z was provided. |
|
I5_ERR_PHP_GETPARAM |
275 |
specific message |
/* Page selection and reading */
$file = i5_open('EASYCOM/NCLIENT');
if (is_bool($file)) trigger_error('i5_open error : '.i5_errormsg(), E_USER_ERROR);
$first = array('CNOM' => 'D');
$last = array('CNOM' => 'F');
$ret = i5_range_from($file, true, $first);
if (!$ret) trigger_error('i5_range_from error : '.i5_errormsg(), E_USER_ERROR);
$ret = i5_range_to($file, false, $last);
if (!$ret) trigger_error('i5_range_to error : '.i5_errormsg(), E_USER_ERROR);
echo 'i5_fetch_row : <BR>';
i5_seek($file, I5_FIRST);
while ($tab = i5_fetch_row($file)) {
printf('%s (%s)<BR>', $tab[3], $tab[2]);
}
echo '<BR>i5_fetch_array : <BR>';
i5_seek($file, I5_FIRST);
$tab = i5_fetch_array($file, I5_READ_SEEK);
while ($tab) {
printf('%s (%s) : ', $tab['CPREN'], $tab['CNOM']);
printf('%s (%s)<BR>', $tab[1], $tab[2]);
$tab = i5_fetch_array($file, I5_READ_NEXT);
}
echo '<BR>i5_fetch_assoc : <BR>';
$tab = i5_fetch_assoc($file, I5_READ_FIRST);
while ($tab) {
printf('%s (%s)<BR>', $tab['CPREN'], $tab['CNOM']);
$tab = i5_fetch_assoc($file, I5_READ_NEXT);
}