Database Abstraction Layer for PHP

User Tools

Site Tools



 mixed execute {
       mixed $sql
       optional string[] $bindvars


This method executes any provided SQL statement. If the SQL statement should return a recordset, e.g. SELECT statements, it returns a handle to an ADOrecordset_array object or false if the statement execution fails. If the statement does not return a recordset, such as in INSERT or UPDATE statement, it returns a handle to an ADOrecordset_empty object on success or false on failure.

The presentation of the returned data can be modified by the $ADODB_FETCH_MODE variable, the ADODB_ASSOC_CASE constant and the setFetchMode() function.


Parameter 1

The first parameter can be either:

  1. A string containing a complete SQL statement. SELECT * FROM ACT
  2. A string containing an SQL statement with bind variables, SELECT * FROM ACT WHERE empno>:emp, in which case the second parameter is an array containing the bind variables.

Parameter 2

If set, contains an array of bind variables.


If the execution succeeds, it returns a recordset. This recordset can be used by functions such as getUpdateSQL() or fetchRow(). if the execution fails, it returns false. You can access errors using errorMsg().


 * Connection assumed
$result = $db->execute("SELECT * FROM ACT");
$result = $db->execute("SELECT * FROM ACT WHERE empno > :emp",
v5/reference/connection/execute.txt · Last modified: 2023/01/15 20:32 by mnewnham