Reputation: 821
I want to get results of left side model/table, if and only if the condition satisfy in the right/contain model for hasMany and BelongsToMany association.
As per my knowledge, joinType is not available for hasMany and BelongsToMany association, so that I can't use InnerJoin...
This is my query,
$this->loadModel('Logins');
$x = $this->Logins->find('all', [
'fields' => ['id', 'user_name'],
'contain' => [
'Sites' => ['conditions' => ['site_id' => 10]]
],
]);
pr($x->enableHydration(false)->toArray());
die;
And This is the result,
[0] => Array
(
[id] => 13
[user_name] => Mal123
[sites] => Array
(
)
)
[1] => Array
(
[id] => 14
[user_name] => rrc
[sites] => Array
(
[0] => Array
(
[id] => 10
[site_name] => Smelter
[site_location] => NA
[client_id] => 1
[site_status_id] => 1
[_joinData] => Array
(
[id] => 15
[login_id] => 14
[site_id] => 10
)
)
)
)
QUESTIONS:-
Upvotes: 0
Views: 118