xpdo modx how to add a condition ON DUPLICATE

159 Views Asked by At

I have a very simple MySQL table and I need to execute this query:

INSERT INTO modx_good (uuid,name) VALUES ('1','name')
  ON DUPLICATE KEY UPDATE uuid='1', name='name';

My table is modx_good:

`id` int(11) NOT NULL AUTO_INCREMENT,
`uuid` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,

And I need to run this using features of modx and xpdo.

I can insert data by

$modGood = $this->modx->newObject('Good');
$modGood->fromArray([ 
  'uuid' => 'a1', 
  'name' => 'name1'
]);
$modGood->save();

But how can I add the ON DUPLICATE KEY condition that I had in the raw query?

0

There are 0 best solutions below