->update() -- Update objects variables into database
Описание
Updates current objects variables into the database. if you supply it with a dataObject, as an
argument, it will only update the differences between the new and old.
Возвращаемое значение
int number of rows affected or FALSE on failure
Throws
Таблица 32-1. Возможные значения PEAR_Error
| Error code | Error message | Meaning | Solution |
|---|
| DB_DATAOBJECT_ERROR_INVALIDCONFIG | "update:No table definition for $table" | | |
| DB_DATAOBJECT_ERROR_NODATA | "update: No Data specifed for query $settings" | | |
Заметка
Эта функция не должна вызываться статически.
Пример
Пример 32-1. Simple fetch and update $person = new DataObjects_Person;
$person->get(12);
$person->name='fred';
$person->update();
$person = new DataObjects_Person;
$person->get(12);
$original = clone($person); // clone is emulated in php4 for compatibility reasons.
$person->name='fred';
$person->update($original); |
|
Пример 32-2. Resulting SQL SELECT * FROM person WHERE id = 12
UPDATE person SET name='fred', age='21', eyes='blue' WHERE id = 12
SELECT * FROM person WHERE id = 12
UPDATE person SET name='fred' WHERE id = 12 |
|