Executes SQL prepared request (stored procedure).
|
bool i5_execute ( |
resource Stmt |
i5_execute executes an SQL request prepared with i5_prepare.
If the SQL request returns a result set, i.e. a SELECT, a line can be collected (as a table or object) from the query resource with i5_fetch_xxx.
If the request creates results sets (CALL statement), i5_next_result function moves pointer to the next available set. If option I5_OPTIONS_AUTOMATIC_NEXT_RESULT wasn’t set to "1" during connection, you need to call i5_next_result() to get the first result set.
i5_execute is much more efficient than i5_query if the same request has to be run several times with only few parameter changes. See i5_prepare for a short statement on using i5_prepare and i5_execute advantages versus i5_query.
A request may contain markers, identified with "?" sign. These markers can be linked to PHP variables (seer i5_bind_param), the results may be linked to PHP variables using i5_bind_result function.
Request or stored parameters may also be allocated using i5_setparam function and collected using i5_getparam function (for IN/OUT or OUT parameters.
|
stmt |
i5_prepare returned request ID |
|
param1 |
Input value parameter matching with marker |
|
params |
Stored request input parameters table including variables markers |
Returns:
Returns a Boolean and update stmt resource in case of success FALSE if it fails.
|
I5_ERR_PHP_HDLBAD |
258 |
Bad connection handle |
|
I5_ERR_PHP_RESOURCE_BAD |
261 |
No resource found . |
|
I5_ERR_PHP_TYPEPARAM |
262 |
Type of element x in parameter -1 must be y. Type z was provided. |
|
I5_ERR_PHP_BINDPARAM |
276 |
Internal error; please contact Aura Equipement; error number 276 |
|
I5_ERR_PHP_VARIABLE |
281 |
You can't use the I5_bind_param function and specify parameters |
The following example prepares a four markers INSERT request, set first time values, calls i5_execute function and then modifies the values before a second call.
$insert = 'INSERT INTO EASYCOM/S_CUSTOMER (CUST_iD, COMPANY, FIRSTNAME, LASTNAME) VALUES (?, ?, ?, ?)';
$req = i5_prepare($insert);
if (is_bool($req)) trigger_error('i5_prepare error : '.i5_errormsg(), E_USER_ERROR);
$newRecord = array(9000, 'Aura', 'walter', 'tribolet');
$result = i5_execute($req, $newRecord);
if (!$result) trigger_error('i5_execute error : '.i5_errormsg(), E_USER_ERROR);
print 'Walter adding sucessful.<BR>';
$newRecord = array(9001, 'Aura', 'benoit', 'anquetin');
$result = i5_execute($req, $newRecord);
if (!$result) trigger_error('i5_execute error : '.i5_errormsg(), E_USER_ERROR);
print 'Benoit adding successful.';