Activates linkage between master file and detail file.
bool i5_link (resource result_master, array keys_master, resource result_detail, array keys_detail)
Parameters
result_master |
master file ID |
result_detail |
Detail file ID |
keys_master |
Master file keys table |
keys_detail |
Detail file keys table |
Return
True if OK, false if failed.
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
i5_link function activates linkage between a master file and a detail file, both files must be opened. Each master file reading will automatically activate a detail file reading.
Only one link can be activated. If i5_link function is called again, first link will be cancelled.
A detail file can only be linked to one master file, but several detail files can be linked to the same master file.
To deactivate link, i5_nolink function must be called.
This function automates filter on detail file, it's like setting a range on one or more key values directly fetched from the master file.
Example
$invoices = i5_open('easycom/s_order');
if (is_bool($invoices))
trigger_error('i5_open master error : '.i5_errormsg(), E_USER_ERROR);
$lines = i5_open('easycom/s_detail');
if (is_bool($lines))
trigger_error('i5_open detail error : '.i5_errormsg(), E_USER_ERROR);
/* Two fields linkage */
$keys_invoice = array('ORDER_ID');
$keys_lines = array('ORDER_ID');
$lien = i5_link($lines, $keys_lines, $invoices, $keys_invoice);
if (!$lien)
trigger_error('i5_link detail error : '.i5_errormsg(), E_USER_ERROR);
$fac = i5_fetch_row($invoices, I5_READ_FIRST);
if (is_bool($fac))
trigger_error('i5_fetch_row Master error : '.i5_errormsg(), E_USER_ERROR);
echo 'Invoice lines are:<BR>';
$lig = i5_fetch_assoc($lines, I5_READ_FIRST);
if (is_bool($lig))
trigger_error('i5_fetch_row detail error : '.i5_errormsg(), E_USER_ERROR);
while (!is_bool($lig)) {
echo $lig['PARTNO']. ' ' . $lig['QUANTITY'] . '<BR>';
$lig = i5_fetch_assoc($lines, I5_READ_NEXT);
}
$ret = i5_nolink($lines);
if (!$ret)
trigger_error('i5_nolink Master error : '.i5_errormsg(), E_USER_ERROR);
See also