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

 

Sets a lower range bound for the file. Once the bound is set, the last entry for all seeks becomes the entry defined by the range.

 

     bool i5_range_to (resource file , bool included, array values)

 

 

Parameters

 

file

IBM i file resource

 

included

True if the field with this key should be included in the range, false otherwise.

 

values

Values of the key=>value pairs.

 

 

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.

 

Details

         Sets the upper filter limit in a file according to key(s) value(s) defined as parameter(s).

         Range can be activated or deactivated for each open file.

         i5_range_from and i5_range_to functions, used together or alone will activate the range.

         To get full file access i5_range_clear function must be used

 

         Using i5_range_from without calling i5_range_to, range will go from specified limit to file end.

         Using i5_range_to without calling i5_range_from, range will go from file start to specified limit.

 

         Upper and lower limits can be set equal:

 

$commun = array("FAMILY" => "WHOLSALERS");

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

$ret = i5_range_to($file, true, $commun);

 

         "included" parameter is a Boolean (TRUE or FALSE) specifying if the limit is included or not in the range.

If the value is FALSE the lower limit (set with i5_range_from) will be the following record and the upper limit (set with i5_range_to) will be the last record.

 

 

Example

 

 

$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]);

}

 

 

See also

i5_seek

i5_range_from

i5_range_clear