Automatically prepares and executes INSERT or UPDATE queries.
This method builds a SQL statement using autoPrepare() and then executes the statement using execute() with it.
name of the table
assoc (key => value), keys are fields names, values are values of these fields
Values are automatically escaped and quoted according to the current DBMS's requirements.
type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE)
a string to be used in the WHERE clause. This is only used when $mode is DB_AUTOQUERY_UPDATE. The string is put directly into the query, so you must escape and quote literals according to the DBMS's standards.
Таблица 34-1. Возможные значения PEAR_Error
Error code | Error message | Reason | Solution |
---|---|---|---|
DB_ERROR_NEED_MORE_DATA | insufficient data supplied | Your associative array, which has to contain fields names and their values, is empty. | Check and correct your fields_values array. |
DB_ERROR_SYNTAX | syntax error | You use an unknown mode. | Available modes are only DB_AUTOQUERY_INSERT for INSERT queries or DB_AUTOQUERY_UPDATE for UPDATE queries. |
DB_ERROR_NODBSELECTED | no database selected | No database was choosen. | Check the DSN in connect(). |
every other error code | Database specific error | Check the database related section of PHP-Manual to detect the reason for this error. |
Эта функция не должна вызываться статически.
Внимание |
The values passed in $data must be literals. Do not submit SQL functions (for example CURDATE()). SQL functions that should be performed at execution time need to be put in the prepared statement. |
Пример 34-1. Using autoExecute() in insert mode
|
Пример 34-2. Using autoExecute() in update mode
|
"Intro - Prepare & Execute", "Intro - autoPrepare & autoExecute", prepare(), execute(), executeMultiple(), autoPrepare()
Пред. | Начало | След. |
DB_common::autoCommit() | Уровень выше | DB_common::autoPrepare() |
HIVE: All information for read only. Please respect copyright! |