Try this:
function search($item = null) {
$item = $this->params['url']['q'];
$recipes = $this->Banco->find('all',
array('conditions' => array(
'AND' => array(
'OR' =>array(
'Recipe.name LIKE' => '%' . $item . '%',
'Recipe.seasonal LIKE' => '%' . $item . '%',
'Recipe.ingredients LIKE' => '%' . $item . '%'),
'Recipe.active' =>'1',
'NOT'=>array('Recipe.active'=> '0'))),
'order' => 'Recipe.name',
'recursive' => 1));
}
Or even simple, because if it's active = 1, can't be active = 0 at same
time. Don't know if you have other possibles values, but take a look at
this:
function search($item = null) {
$item = $this->params['url']['q'];
$recipes = $this->Banco->find('all',
array('conditions' => array(
'AND' => array(
'OR' =>array(
'Recipe.name LIKE' => '%' . $item . '%',
'Recipe.seasonal LIKE' => '%' . $item . '%',
'Recipe.ingredients LIKE' => '%' . $item . '%'),
'NOT'=>array('Recipe.active'=> '0'))),
'order' => 'Recipe.name',
'recursive' => 1));
}
On Wed, Feb 11, 2009 at 4:37 PM, monirr444 <[email protected]> wrote:
>
>
> here is the code i want to search but not inactive ones i have this code so
> far it wont work
> thank you helping the other time
> if u can help with that would be great
>
> function search($item = null) {
> $item = $this->params['url']['q'];
> $recipes = $this->Recipe->find('all', array('conditions' => array(
> 'OR' =>array(
> 'Recipe.name LIKE' => '%' . $item . '%',
> 'Recipe.seasonal LIKE' => '%' . $item . '%',
> 'Recipe.ingredients LIKE' => '%' . $item . '%')),
> 'AND' => array(
> array(
> 'OR'=>array(
> 'Recipe.active' =>'1'),
> 'NOT'=>array(
> 'Recipe.active'=> array('0')),
> 'order' => 'Recipe.name',
> 'recursive' => 1,
>
>
> ))));
> --
> View this message in context:
> http://n2.nabble.com/help-with-complex-condations-brian-9-tp2310476p2310476.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---