Sends SQL request and possibly collects results set.
resource i5_ query (string query [, resource connection])
Parameters
query |
SQL request to be performed |
connection |
Connection ID (optional). |
Return
TRUE or SELECT request type ID or FALSE in case of failure.
I5_ERR_DESC_WRONG_DATAOP |
41 |
Wrong operation on a data field of a description |
I5_ERR_PARSEXML |
42 |
Internal error; please contact Aura Equipements. error number 42 |
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. |
Detail
SELECT request type i5_query returns a resource in case of success or FALSE in case of error.
For UPDATE or DELETE request type, i5_query returns TRUE in case of success or FALSE in case of error.
i5_query function is the most suitable for all easy processing, without parameter requests. Otherwise, a parameterized request type like (i5_prepare and i5_execute) must be used.
Example
/* Straight request execution */
$query = i5_query('SELECT * FROM EASYCOMXMP/SP_CUST');
if(is_bool($query))
{
echo "Error code: " . i5_errno() . "<br>";
echo "Error message: " . i5_errormsg() . "<br>";
}
else
{
/* Data’s reading and displaying */
echo "<table>";
while ($values = i5_fetch_row($query, I5_READ_NEXT ))
{
echo "<tr>";
echo "<td>" .$values[0]. "</td>";
echo "<td>" .$values[1]. "</td>";
echo "<td>" .$values[2]. "</td>";
echo "<td>" .$values[3]. "</td>";
echo "<td>" .$values[4]. "</td>";
echo "<td>" .$values[5]. "</td>";
echo "</tr>";
}
echo "</table>";
}
See also: