I can't get a user data condition requested with a null and spesific id
<?php
function someController()
{
$user_id = $this->Session->read('Auth.User.id');
$this->Announcement->recursive = 1;
$this->paginate = array
(
'conditions' => array
(
'Announcement.user_id' => array($user_id,null)
),
'limit' => 6
);
debug($this->paginate());
}
?>
the problem is in the
array($user_id, null) section. When i requested it with
array($user_id, $ANOTHER_ID) it works. But i need to get null id assigned rows.
Thanks in advance
Asked by JacopKane.myopenid.com, on 8/2/10
2 Answers
why not make the default for the field 0 and then set 'Announcement.user_id' => array($user_id,0)
that might help
Answered by dogmatic69on 8/2/10
well i guess it is. i will open a ticket, thanks for your support
JacopKane.myopenid.com - on 8/2/10
How embarrassing, this should read:
'conditions'=> array(
'or' => array(
array( 'Announcement.user_id' => null),
array( 'Announcement.user_id' => $user_id)
)
)
Need an extra set of array() s in there to prevent the key collision. Sorry about that.
davidwu - on 9/2/10
<< previous next >>
Tagged with
Rating
0
Viewed
327 times
Last Activity
on 9/2/10