Method Mysql.SqlTable()->update()
- Method
update
voidupdate(mapping(string:mixed)record,void|int(0..2)clear_other_fields)- Description
Updates an existing record. This requires a primary key and that
recordcontains values for all primary key columns. Ifrecorddoesn't correspond to any existing record then nothing happens.Updating a record normally means that all fields in
recordoverride those stored in the table row, while all other fields keep their values.It's the same for properties (i.e. fields that don't correspond to columns) which are stored in the prop_col column. If that column needs to be updated then by default the old value is fetched first, which means the update isn't atomic in that case. A property can be removed altogether by giving it the value Val.null in
record.If
clear_other_fieldsis 1 then all old properties are replaced by the new ones instead of merged with them, which avoids the extra fetch. Ifclear_other_fieldsis 2 then additionally all unmentioned columns are reset to their default values.For more details about the
recordmapping, see insert.- See also