insert or replace data / on duplicate key update for multiple insert
- Flachag
- Member | 2
Hey,
I use Nette Database and I didn't find how to use “on duplicate key update” for multiple insert:
I use multiple insert like this:
$database->query('insert into machines (id, name, latitude, longitude)',$machinesData, 'ON DUPLICATE KEY UPDATE', [
'name' => '###' ,
'latitude' => '###',
'longitude' => '###' ,
'address' => '###' ,
'zipcode' => '###'
]);
I don't know what I'm supposed to put for the duplicate key. In SQL I would do like this:
insert into machines (id ,name, latitude, longitude) values
(?,?,?,?)
on duplicate key update
id=VALUES(id),
name=VALUES(name),
latitude=VALUES(latitude),
longitude=VALUES(longitude)";
Someone know how to do the same thing with nette Database ?