Blizz
(Blizzke)
October 2, 2014, 7:44am
1
How would one handle a more complex mass update in Yii2 without having to fall back on literal queries?
I’m talking something in the sense of
UPDATE table_name SET column1 = value, column2 = CONCAT(column2, "Extra") WHERE TIMESTAMPDIFF(NOW(), column3) > 600
And as mentioned above, of course it is possible with a “raw query”, just wondering if there is a more code friendly way
samdark
(Alexander Makarov)
October 2, 2014, 9:03am
2
I’d use raw query for it since in this case you are sure what will be done and since it’s applied to many entries it’s extremely important.
I think it can be done with Query as well. Probably you’ll need to wrap some parts with Expression.
Blizz
(Blizzke)
October 2, 2014, 9:26am
3
Yeah that’s what I was afraid for. It’s not that bad, I simply don’t like the sight of “raw sql” in my code all of a sudden and the query interface is quite elegant.
Thanks for the reply.