- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:reference:connection:execute

# execute

##### syntax

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

## Description

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

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.txt · Last modified: 2016/01/18 16:55 by 66.249.75.225

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top