D
D
devilsD2016-01-22 17:11:59
Yii
devilsD, 2016-01-22 17:11:59

Yii How to correctly form criteria For the HAS_MANY connection?

0
vote against
favorites
Good afternoon. There is a POST model. And there is a model category_r In the last 3 columns: id, Post_id, category_id.
I need to make a selection of posts where category_id is equal to 1 and 2 for example. HERE are my criteria:

$criteria->condition = 'category.category_id=2 AND category.category_id=1';

Gives an error in the sql query, If you add $criteria->together = true;Then returns an empty model. With one condition, for example
criteria->condition = 'category.category_id=2' - тут все отлично.

Please tell me how to implement it

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question