Creating a Generic Query Function
The interactions in this eCourse require Javascript to be enabled.
Creating a Generic Query Function
previous|next
The hr_db.inc file contains a db_do_query() function that performs the following steps (with OCI8 library calls shown) to execute a query, optionally with bind variables:
Parse the query string with oci_parse().
Assign PHP variable values to query bind variables with oci_bind_by_name().
Execute the query with oci_execute().
Fetch the result set with oci_fetch_all(). Take care using this OCI function with large result sets.
The db_do_query() function provides the following parameters:
$conn for the connection identifier
$statement containing the query string
$resulttype specifying how the result set is return, either as an array of rows each containing an array of columns (the default OCI_FETCHSTATEMENT_BY_ROW), or as an array of columns each containing an array of the row values in that column (OCI_FETCHSTATEMENT_BY_COLUMN)
$bindvars: an optional array containing one or more bind variable arrays. Each bind variable array may contain the name of the bind variable in the query, the value to be associated with the bind variable, and a length of the value.
For IN bind variables, which provide input values to a query, the length can be set to -1. In this case, the OCI8 layer dynamically determines the length of the value. For OUT bind variables, for values returned by a query, the length must be set to a suitable value for the expected result.
The db_do_query() function returns the result set as an array or rows or columns, depending on the value of the $resulttype parameter. The function returns a false value if an error occurs.
Wyszukiwarka
Podobne podstrony:
les09 page handling tmles09 cre ui tmles09 disp?pt tmles09 create? logic tmles09 crectl logic tmles09 credb connect tmles09 get?pt tmles09 login page tmles09 logout page tmles09 get emp tmles09 disp emp tmles09 create? conn prop tmles09 getstart tmTM 08 termin Iles09 styles cssFanuc 11M [TM] CQ07 16 2TM UARTUlotka Pytania dotyczące TS, ETPCz, TMwięcej podobnych podstron