i5_fetch_object

 

Returns result line as object or NULL if there is no more line.

 

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 )

 

Details

 

i5_fetch_object function returns results set current line as an object. Its attributes represent fields names founded in the results set.

If there is no more result, i5_fetch_object function returns NULL.

 

i5_fetch_xxxx functions (default) move the pointer one step forward (I5_READ_NEXT) before reading, it is possible to specify another move direction or position.

To fetch current record consecutive to i5_seek or i5_data_seek, I5_READ_SEEK option will read the line without moving pointer.

 

I5_READ_NEXT

Read following record

I5_READ_PREV

Read previous record

I5_READ_FIRST

Read first record

I5_READ_LAST

Read last record

 

 

I5_READ_SEEK

Read current record

 

Any attempt to read out of the file will return NULL and activate an I5_ERR_BEOF error type.

 

Parameters

 

result

connection ID

option

Easycom constant setting move direction

 

Returns:

Returns an object with record values or NULL if there is no more line or FALSE in case it fails.

 

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

 

 

Example

 

/* Makes and reads a selection */

$file = i5_open("EASYCOM/NCLIENT");

$first = array("NAME" => "D");

$last = array("NAME" => "E");

$ret = i5_range_from($file, true, $first);

if (is_bool($ret) && $ret == FALSE)
trigger_error("i5_range_from error : ".i5_errormsg(), E_USER_ERROR);

$ret = i5_range_to($file, FALSE, $last);

if (is_bool($ret) && $ret == FALSE)
trigger_error("i5_range_to error : ".i5_errormsg(), E_USER_ERROR);

 

$obj = i5_fetch_object($file, I5_READ_FIRST);

while (!is_bool($obj) && ($obj != NULL)) {

echo "Name : ".$obj->CNOM." (".$obj->CCODE.")<BR>";

$obj = i5_fetch_object($file);

}


/* SQL request */

$sql = "SELECT LASTNAME, COUNTRY, ZIP FROM easycom/s_customer ORDER by cust_id DESC";
$result = i5_query($sql);
if (is_bool($result))
trigger_error("i5_query error : ".i5_errormsg(), E_USER_ERROR);

 

/* Reads last line */

$obj = i5_fetch_object($result, I5_READ_LAST);

printf("Last : %s (%s)<BR>", $obj->LASTNAME, $obj->ZIP);

 

/* Reads first line */

$obj = i5_fetch_object($result, I5_READ_FIRST);

printf("First : %s (%s)<BR>", $obj->LASTNAME, $obj->ZIP)

 

$obj = i5_fetch_object($result);

/* Scrolling from begining to end */

while (!is_bool($obj) && $obj != NULL) {

printf("%s (%s)<BR>", $obj->LASTNAME, $obj->ZIP);

$obj = i5_fetch_object($result);

}

See also

 

i5_fetch_array

i5_fetch_row

i5_fetch_assoc

i5_result

i5_getblob