| ADOdb Library for PHP Manual | ||
|---|---|---|
| Prev | Prepare | Next |
Prepares (compiles) an SQL query for repeated execution. Bind parameters are denoted by ?, except for the oci8 driver, which uses the traditional Oracle :varname convention.
Returns an array containing the original sql statement in the first array element; the remaining elements of the array are driver dependent. If there is an error, or we are emulating Prepare( ), we return the original $sql string. This is because all error-handling has been centralized in Execute( ).
Example:
$stmt
= $DB->Prepare('insert
into table (col1,col2) values (?,?)');
for ($i=0; $i < $max; $i++)
$DB->Execute($stmt,array((string)
rand(), $i));
Also see PrepareSP(). Only supported internally by interbase, oci8 and selected ODBC-based drivers, otherwise it is emulated. There is no performance advantage to using Prepare() with emulation.
Important: Due to limitations or bugs in PHP, if you are getting errors when you using prepared queries, try setting $ADODB_COUNTRECS = false before preparing. This behaviour has been observed with ODBC.
| Prev | Home | Next |
| CacheFlush | Up | PrepareSP |