On Monday, 9 April 2012 12:22:56 UTC+2, JonStark wrote:
>
> Hello every one.
>
> I'm stuck with a little piece of code :
>
> $condition = array('User.role' =>* 'admin'||'author')*;
>     $this->set('users', $this->paginate('User', $condition));
>
> It seems that OR (*||) *Isn't working with array... 
>

except, that's not what || means in php

 $ php -a
Interactive shell

php > $foo = 'admin'||'author';
php > echo $foo;
1
php > var_dump($foo);
bool(true)


but I have a 3 role blog, and I want to regroup authors and admins on 
> display :
>
> $condition = array('User.role' =>* 'admin'||'author')*;
>

Have a look at the query you're executing, it is going to return 
nothing. You probably want:

    $condition = array('User.role' => array('admin', 'author'));

AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to