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

 

 Check if current record match the latest requested key value.

 

   bool i5_ match (resource file [, int key_fields_count ] [, int Last_field_len ])

 

 

Parameters

file

IBM i file resource.

key_fields_count

When the access key is composed by multiple fields, "key_fields_count" represents the count of fields to consider when comparing the key values.

If "key_fields_count" is omitted, the size of the key given on the latest call to i5_seek will be applied.

last_field_len

When the access key is composed by multiple fields, "last_field_len" represents the size to consider for the last key field, when comparing the key values.

If "last_field_size" is omitted, the size original size of the key field is applied.

 

Return

True if match, false otherwise.

 

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.

 Details

 The key value for the current record is compared to the key value provided to the latest i5_seek function call.

 

 

Example

 

 

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

 

/* Looking for MARTIN */

$seek = array("MARTIN");

/* Looking for martin pierre*/

//$seek = array("MARTIN ", "PIERRE");

 

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

 

$rec = i5_fetch_row($file, I5_READ_SEEK);

if (is_bool($rec))

trigger_error("i5_fetch_row error : ".i5_errormsg(), E_USER_ERROR);

 

$ret = i5_match($file);

if ($ret == true)

                    echo "Record found<BR>";

else if($ret == false) && ((i5_errno() == I5_ERR_OK   || i5_errno() == I5_ERR_RECORDNOTFOUND))

                   echo "Record no found<BR>";

else

{

                   var_dump(i5_error());

                   trigger_error("i5_match error : ".i5_errormsg(), E_USER_ERROR);

}

 

/* Set a bookmark on current record */

$dupont = i5_bookmark($file);

 

[... others treatments on the file ...]

 

/* Direct return to back to DUPONT record */

$ret = i5_data_seek($file, $dupont);

if (!$ret)

trigger_error("i5_data_seek error : ".i5_errormsg(), E_USER_ERROR);

 

$rec = i5_fetch_row($file, I5_READ_SEEK);

if (is_bool($rec))

trigger_error("i5_fetch_row error : ".i5_errormsg(), E_USER_ERROR);

 

print_r($rec);echo "<BR>";

 

 

 

See also

i5_seek

i5_fetch_xxx