I'm trying to run this sql query as a php activerecord query:
delete from article_categories where
article_id = 10
and
category_id in (1,4,5,6,7)
This statement works fine when I run it from the mysql console.
I tried doing this from php activerecord:
$query["conditions"] = array('article_id = ? and category_id in (?)', 10, "1,4,5,6,7");
ArticleCategory::delete_all($query);
The problem is it is only deleting one record at a time.
I expect all the records that match
article_id == 3
and
category_id == 1 || category_id == 2 || ... || category_id == 5
to be deleted.
However only the first record with fields article_id = 3, category_id = 1
gets deleted.
What am I typing wrong?
I'm not really sure if the ID you're sending it to delete can be empty? The documentation shows this for "Massive Update or Delete".
So, translated in your situation that would be something like