ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:cacheexecute

cacheExecute

Use of $ADODB_FETCH_MODE and setFetchMode() is incompatible with use of cached result sets as the results of the cached query are stored using the original fetch mode settings.

syntax
 mixed cacheExecute {
       mixed $cacheTimeInSeconds,
       optional 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.

  1. If the first parameter passed is a positive integer, then the query cache is searched for a matching query cached within that period. If no matching cache file is found, A new statement is executed and cached.
  2. If the first parameter is the SQL statement, the query cache default is used $cacheSecs

Parameters

Parameter 1

The first parameter can be either:

  1. A positive integer e.g. 600
  2. A string containing a complete SQL statement, such. SELECT * FROM ACT
  3. 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
  4. A array of SQL Statements. This is only available to internal functions.

Parameter 2

either the SQL statement or if set, an array of bind variables.

Parameter 3

if set, 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->cacheExecute(6000,"SELECT * FROM ACT");
 
or: 
 
$result = $db->cacheExecute("SELECT * FROM ACT WHERE empno > :emp",
             array('emp'=>1234)
            );
 
v5/reference/connection/cacheexecute.txt · Last modified: 2016/05/15 15:27 by mnewnham