ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:execute

This is an old revision of the document!


Execute

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

Description

The function executes a statement and returns a handle to a recordset or false if the statement execution fails. The presentation of the returned data can be modified by the variables $ADODB_FETCH_MODE and $ADODB_ASSOC_CASE and the function setFetchMode().

Parameters

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
  3. A array of SQL Statements. This is only available to internal functions.

Parameter 2

If set, contains an array of bind variables.

Result

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().

Usage

/*
 * Connection assumed
*/
$result = $db->execute("SELECT * FROM ACT");
 
or: 
 
$result = $db->execute("SELECT * FROM ACT WHERE empno > :emp",
             array('emp'=>1234)
            );
 
v5/reference/connection/execute.1437488485.txt.gz · Last modified: 2017/04/21 11:35 (external edit)