Reputation: 1593
$this->paginate['Member'] = array(
'conditions' => array($conditions,'Member.division_id' => $currentTeam['Division']['id'],'Member.team_id'=> array(null,0)),
'group' => 'Member.id',
);
This query does not get the NULL team id.. It gets just the team id 0.
Upvotes: 2
Views: 13822
Reputation: 743
$this->paginate['Member'] = [
'conditions' => [
$conditions,
'Member.division_id' => $currentTeam['Division']['id'],
'OR' => [
['team_id' => null],
['team_id' => 0],
],
'group' => 'Member.id',
];
Wrapped each team_id
condition in it's own array. This prevents the issue of a duplicated team_id
array key, while still using a consistent format for the conditions.
Upvotes: 9
Reputation: 6780
array(
$conditions,
'Member.division_id' => $currentTeam['Division']['id'],
'OR' => array(
'Member.team_id' => 0,
'IS' => array( 'Member.team_id' => NULL )
)
)
This is what you want.
Upvotes: 2
Reputation: 87073
$this->paginate['Member'] = array(
'conditions' => array($conditions,
'Member.division_id' => $currentTeam['Division']['id'],
'OR'=> array('Member.team_id'=> null, 'Member.team_id'=> 0),
'group' => 'Member.id',
);
Upvotes: 0
Reputation: 33163
Using the IS NULL keyword usually works.
array(
$conditions,
'Member.division_id' => $currentTeam['Division']['id'],
'OR' => array(
'Member.team_id' => 0,
'Member.team_id IS NULL'
)
)
Upvotes: 12