PreviousNext
Help > API Functions > Native database access > i5_seek
i5_seek

 

Moves the internal result pointer. The next call to a data recovery function, like the i5_fetch_ * functions, will return this line.

 

Syntax n°1

 

  bool i5_ seek (resource file ,int/string operator [, array keyvalue ][, int Last_field_len )

 

Syntax n° 2

 

   bool i5_ seek (resource file , int/string operator[, int bookmark ])

 

 

Parameters

file

IBM i file resource.

operator

 

 

 

 

 

 

 

 

 

Comparison operator. Position is set to first record satisfying the operator.

Operator can be specified as a symbolic or string value.

Symbolic value

String value

Description

I5_EQ

"="

Equal

I5_GE

">"

Greater than

I5_GT

">="

Greater or Equal

I5_LT

"<"

Less than

I5_LE

"<="

Less or Equal

I5_FIRST

"FIRST"

First record: No key value is required.

I5_LAST

"LAST"

Last record: No key value is required.

I5_BOOKMARK

"BOOKMARK"

Go to record number

keyvalue

Values of the keys to locate to.
If the key is composed by multiple fields, each entry in array "key => value" contains the value for one field.

 

last_field_len

Length of the last field.
When the key is composed by multiple fields, the "Last_field_len" parameter represents the number of characters to consider for the last given field, when looking for the record.

If "Last_field_len" is omitted, the last given key field will be considered in its full size.

If "Last_field_len" has special value I5_ACTUAL_SIZE, the current contain size of the cell in "key value” array, will be considered for the last field.

 

bookmark

Integer. Record Number.

 

Return

True if OK, false if failed.

 

Error returned

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_TYPEGET

264

The x function is unable to translate this type (-1).

I5_ERR_PHP_OPERATOR_BAD

265

Unknown operator (x)

I5_ERR_FIELDNULL

4097

Field value is NULL

 

 Details

This function is typically used to search in a file according to a key (simple or composite). It locates the record that fills the specified requirement for a defined index.

See functions i5_range_from and i5_range_to to select a range of records.

 

i5_seek moves the pointer without reading the result, next call to i5_fetch_xxxx will return the line.

 

Example

 

 

    $fil = i5_open("EASYCOMXMP/S_ORDER", I5_OPEN_READWRITE,$Hdlcon);

    if(is_bool($fil))

    {

                   print_r("i5_open error : ".i5_errormsg().'<br/>');

    }

    else

    {

                   $seek = array("1003");

                   $ret = i5_seek($fil, I5_EQ, $seek);

                   if (!$ret)

                   {

                                   print_r("i5_seek error : ".i5_errormsg().'<br/>');

                   }

                   else

                   {

                                   $rec = i5_fetch_row($fil, I5_READ_SEEK); 

 

See also

 i5_data_seek

i5_fetch_xxx

i5_match