2

I'm using Propel 2 and am trying to do a batch update of records. The following works as expected:

//UPDATE animal SET species='Duck';
AnimalQuery::create()->update(['Species' => 'Duck']);

However, I'm not sure what to do if I want to do something like the following:

UPDATE animal SET species=REPLACE(species, 'Mallard', 'Duck');

Is this possible using Propel?

zeke
  • 3,603
  • 2
  • 26
  • 41

1 Answers1

1

The following query has the same outcome as the query you state would meet your needs.

AnimalQuery::create()->filterBySpecies("Mallard")->update(['Species' => 'Duck']);

It will issue the following query. UPDATE animal SET species='Duck' WHERE species='Mallard';

Does that meet your needs?

Ben
  • 713
  • 4
  • 12