I just trying to save or insert data into a mysql from inside a custom module.
The table is 'my_table'.
I use this to insert:
db_insert('my_table')->fields(array(
'name' => 'Andy',
'last_name' => 'Moore',
))->execute();
and this to update:
db_update('my_table')
->fields(array(
'name' => 'John'
))
->condition('last_name', 'Moore')
->execute();
So far so good, but now I need to update or insert a value:
If 'name=George' exist then update its 'last_name=Niels'. Otherwise if 'name=George' doesn't exist then create insert it with this values 'name=George' and 'last_name=Niels'