thanks Reuben,... 
after all,... (in case someone needs it) this works for me: 

this is my form: 

<?php echo $this->Form->create('User', array('url' => 'find', 'div' => 
false)); ?>
<span style="float: left; text-align: left; margin: 20px 5px 0 5px;  width: 
100px; ">
<?php $value = array('yes' => __('yes', true), 'no' => __('no', true)); ?>
<?php echo $this->Form->select('activated', $value, null, array('div' => 
false, 'empty' => 'activated' ))  ?>
</span>
     <div style="float: left; text-align: left; margin: 0 0 0 20px;">
<?php echo $this->Form->end('Search', array('div' => false)); ?>
    </div>

and here is the controller code: 
elseif(!empty($this->data['User']['activated'])) 
{
 $this->paginate = array('User' => array('conditions' => array('User.token 
IS' . ($this->data['User']['activated'] == 'yes' ? '' : ' NOT') . ' ' . 
'NULL' ), 'limit' => 24, 'order' => array('User.created' => 'DESC')));
       $users = $this->paginate('User');
       $this->set('users', $users);
} 

the cake is Rocks !!!


On Friday, May 10, 2013 8:09:39 PM UTC-7, Reuben wrote:
>
> I would advise expanding that condition code, as it's hard to read. Or 
> just arrange it a bit differently.
>
> Currently, you'll end up with User.token LIKE IS NULL or User.token LIKE 
> NULL, and neither of those will work with regular SQL.  CakePHP is smart 
> enough to recognise equality or inequality with nulls, so you could do the 
> following:
>
>         $this->paginate = array('User' => array('conditions' => 
> array('User.token ' . $this->data['User']['activated'] == 'yes' ? '' : '!=' 
> => NULL )));
>
> Essentially, this determines what operator to use, depending on 
> User.activated.  A value of yes results in equality with null, otherwise 
> inequality with null, and CakePHP will correctly result in User.token IS 
> NULL or User.token IS NOT NULL.
>
> Regards
> Reuben Helms
>
> On Thursday, 9 May 2013 20:37:15 UTC+10, Chris wrote:
>>
>> hi guys,... can anyone help please,... 
>>
>> I trying to search users table werther's user token IS NULL or NOT (what 
>> it means is user activated, confirmed or not) 
>> having some problem with coding,... 
>>
>>         $this->paginate = array('User' => array('conditions' => 
>> array('User.token LIKE'=>'IS'.($this->data['User']['activated'] == 'yes' ? 
>> '' : 'NOT') . ' NULL' )));
>>
>> thanks in advance 
>> chris
>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to