====== execute ====== ~~NOTOC~~ == syntax == object|bool execute { mixed $sql optional string[] $bindvars = null optional string[] $cacheDataArray = null } ===== 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 [[v6:reference:adodb_fetch_mode|ADOConnectionDefinitions::fetchMode]] class variable, the [[v6:reference:adodb_assoc_case|ADOConnectionDefinitions::assocCase]] class variable and the [[v6:reference:connection:setfetchmode|setFetchMode()]] function. The function also supports use of caching using the [[v6:memcache|cache data array]] ===== Parameters ===== ==== Parameter 1 ==== The first parameter can be either: - A string containing a complete SQL statement. ''SELECT * FROM ACT'' - 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. === Parameter 3 === Cache data configuration ==== Result ===== If the execution succeeds, it returns a recordset. This recordset can be used by functions such as [[v6:reference:connection:getupdatesql|getUpdateSQL()]] or [[v6:reference:recordset:fetchrow|fetchRow()]]. if the execution fails, it returns false. You can access errors using [[v6:reference:connection:errormsg|errorMsg()]]. ==== Usage ==== /* * Connection assumed */ $result = $db->execute("SELECT * FROM ACT"); or: $result = $db->execute("SELECT * FROM ACT WHERE empno > :emp", array('emp'=>1234) );