tuga
(Tuga74)
1
Hi,
How can I build this query for ActiveRecord::deleteAll() or how can i use many operators?
DELETE from venues_categories WHERE category_id NOT IN(8,9) AND venue_id = 103
I can use :
VenuesCategories::deleteAll(['not in', 'category_id', $categoriesList]);
But how can I add the other operator, I think i’m missing something.
Thank you for your help.
mmbalaa
(Mmbalasundaram)
2
If you want, try this method
$model = $connection->createCommand('DELETE from venues_categories WHERE category_id NOT IN(8,9) AND venue_id = 103
');
$model->execute();
mmbalaa
(Mmbalasundaram)
3
User::deleteAll('category_id IN :category_id AND venue_id > :venue_id ',
[':category_id ' => $categoriesList, ':venue_id ' => 103]);
tuga
(Tuga74)
4
Thank you, I thought there was another way beside the string form
tuga
(Tuga74)
5
I was able of producing the right query using
VenuesCategories::deleteAll(['and', 'venue_id = :venue_id', ['not in', 'category_id', $categoriesList]], [
':venue_id' => 103
]);
I think I should start with the "and" operator and not the "not in"
Thanks anyway