Method Mysql.SqlTable()->insert_or_update()
- Method
insert_or_update
intinsert_or_update(mapping(string:mixed)record,void|int(0..2)clear_other_fields)- Description
Insert a record into the table using an INSERT ... ON DUPLICATE KEY UPDATE command: In case
recordconflicts with an existing record then it is updated like the update function would do, otherwise it is inserted like insert would do.If id_col is set and that column doesn't exist in
recordthen the field is added to the mapping with the value that the inserted or updated record got.- Returns
The value of the id_col column for the new or updated record. Zero is returned if there is no id_col column.
- Note
This function isn't atomic if
clear_other_fieldsis unset andrecordcontains fields which do not correspond to real columns, i.e. if the prop_col column may need to be updated.