with insert on duplicate key update - updating multiple rows at once

by almost okey   Last Updated September 16, 2018 13:10 PM

With latest joomla version I try to achieve one query to the database and updating multiple rows at once.

I want to make a query like this:

INSERT INTO `tablename`
(`id`,`date`) VALUES 
('79','2018-12-01'),('78','2018-10-01'),('76','2018-06-01'),('80','2019-01-01')
ON DUPLICATE KEY UPDATE
(`date` = '2018-12-01'),(`date` = '2018-10-01'),(`date` = '2018-06-01'),(`date` = '2019-01-01')

If I setup this and debug:

$query
        ->insert($db->quoteName('#__tablename'))
        ->columns($db->quoteName($columns))
        ->values($values);

this only produces the first 3 row of my wanted query. How can I extend to add the text "ON DUPLICATE KEY UPDATE" and another array values to the end? Or there is another way of doing this? Its possible to add multiple query to setQuery, or concatenate queries?



Related Questions


Joomla query for monthly result in a graph

Updated February 27, 2017 14:10 PM