i5_fetch_assoc

 

Fetches result line as associative table.

 

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

 

Returns associative table of next result line.

 

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

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

 

I5_READ_NEXT

Read the next record

I5_READ_PREV

Read the previous record

I5_READ_FIRST

Read the first record

I5_READ_LAST

Read the last record

 

 

I5_READ_SEEK

Read the current record

 

An attempt to read out of the file will returns NULL and create an I5_ERR_BEOF error type.

 

Parameters

 

result

File or request ID

option

Easycom constant specifying scanning direction

 

Returns:

Returns an associated table or NULL if there is no more line or FALSE in case of error.

 

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

 

/* selects and reads a segment */

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

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

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

$ret = i5_range_from($file, ">=", $first);

$ret = i5_range_to($file, "<", $last);

 

while ($tab = i5_fetch_assoc($result)) {

       printf ("%s (%s)\n", $tab["FIRSTNAME"], $tab["NAME"];}

 

$sql = "SELECT Name, Country code FROM City ORDER by ID DESC";
$result = i5_query($sql)


if ($result) {

 

    /* Reads last line */

    $obj = i5_fetch_assoc($result, I5_READ_LAST);

 

    /* Reads first line */

    $obj = i5_fetch_assoc($result, I5_READ_FIRST);


    /* Proceeds from beginning to end */

    while ($obj = i5_fetch_assoc($result)) {

       printf ("%s (%s)\n", $tab["NAME"], $tab["PRENOM"];}

 

 

 

/* Returns the record as an associative table */

$sql = "SELECT * FROM CONTACTS";

$res = i5_query($sql);

 

$rec = i5_fetch_assoc($res);

 

echo "Name: " . $tab["NAME"] . "<br>";

echo "First name: " . $tab["FIRSTNAME"] . "<br>";

 

 

See also

 

i5_fetch_array

i5_fetch_row

i5_fetch_object

i5_result

i5_getblob