Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Strict Comparison Cdbcriteria. How ?

$
0
0
Hi.
I'm using "many to many" relations, and i'm trying to write search based on strict comparison for some properties of model, which is "many to many" relationship.
If i writing IN condition (by method addInCondition) for this relationship - it's not strict searching 'cause
query match to each model, which satisfy to at least one of seted in addInCondition values. I wish to get models, which satisfy all seted velues in addInCondition.

For exapmle:
table user
id.....name
1......John
2......Mary

table user_to_country
user_id.....country_id
1................1
1................3
2................2
2................1

table country
id................country_name
1................United Kingdom
2................Ukraine
3................Afganistan

If i set :
$criteria->addInCondition('country_id', array(1, 3));
In result i'm retreive John and Mary, but i wish to get only John, 'cause only it match to all values, which seted in addInCondition (1, 3)

Thank you in advance.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>