Database Abstraction Layer for PHP

User Tools

Site Tools


This is an old revision of the document!


  bool AutoExecute(
     string $tables,
     string[] $arrFields,
     string $mode,
     optional mixed $where
     optional bool $forceupdate
     optional bool $magicq

$ADODB_QUOTE_FIELDNAMES provides control over the quoting and casing of fieldnames, especially useful when fieldnames contain special characters


AutoExecute can automatically generate and execute INSERT and UPDATE statements on a given table with this function, and is a wrapper for GetInsertSQL() and GetUpdateSQL()

AutoExecute() inserts or updates `$table` given an array of `$arrFields`, where the keys are the field names and the array values are the field values to store. Note that there is some overhead because the table is first queried to extract key information before the SQL is generated. We generate an INSERT or UPDATE based on `$mode` (see below).


The name of the table to update


An associative array of field⇒value pairs


Legal values for `$mode` are



The $where clause is required if $mode == 'UPDATE'.


false(default). Only fields that have been modified are updatedThe database record is re-read before update
trueAll fields provided are updatedThe constructed statement may be considerably larger


falseDoes not attempt to quote special characters in character fields e.g. \0
trueAttempts to quote special characters, e.g. \0 becomes \\\0 to allow database insertion


AutoExecute($table, $arrFields, $mode, $where=false, $forceUpdate=true,$magicq=false)

Insert example

$table               = 'people'
$record["firstName"] = "Carol";
$record["lastName"]  = "Smith"; 
 * result executes "INSERT INTO people (firstName,lastName) values ('Carol',Smith')";

Update example

$table               = 'people'
$record["firstName"] = 'Carol';
$record["lasTname"]  = 'Jones'; 
$where               = "lastname like 'Sm%'";
$conn->AutoExecute($table,$record,'UPDATE', $where);
 * result executes "UPDATE people SET firstName='Carol',lasTname='Jones' WHERE lastname like 'Sm%'";
v5/reference/connection/autoexecute.1437316710.txt.gz · Last modified: 2017/04/21 11:37 (external edit)