Wiki
prep / Prep_class / updateone_func
Prep::updateOne method
bool Prep::updateOne(~prep\Table $table, int $ID, mixed $fields[, null, null, PDO $PDO[, string $field_ID]]); bool Prep::updateOne(array $arguments);
Inits a prep\Query object, executes it with the prep\Query::exec method on a single row.
This is a method of the Prep class.
This method is static.
Reference
Arguments
- ~
prep\Table$table The table used for the query - int $ID The unique identifier for the row you want to update. The column checked is
$field_ID - mixed $fields
- ~
prep\FieldThe one field you want to update - array
- associative array
keyrepresents the field namevaluerepresents the new value of the field (The string values will be protected from SQL injection)
- list of ~
prep\FieldThe fields you want to update - Both of the above
- associative array
- ~
- Ignored argument
- Ignored argument
PDO$PDO- Required if the default
Prep::$PDOis not set - If provied, will override the default one if is a (subclass of)
PDO
- Required if the default
- string $field_ID Default is
ID! The name of the column containing the identifier of the row you want to select. As the limit is set to 1, you would rather choose a column with an unique index (or primary).
⇒ The arguments may be given as well as different arguments or into one single array as documented in prep\ArgumentException::checkArgs
Returned value
A bool : true if the update was successful.
Exception throwing
- Throws a
prep\MissingArgumentExceptionif no table or no field is provied. - Throws a
prep\WrongTypeArgumentExceptionif the table provied cannot be interpreted as aprep\TableInterface. - Throws a
prep\MySQLErrorExceptionif a MySQL error triggers. - Throws a
prep\QueryFailedExceptionif$IDis not found or if the update fails.
Exemples
To be continued...
It has basically have the same expected arguments as Prep::update. You should read its documentation and exemples.
See also
Updated