Ok, I have found the problem and a fix: The problem is that the first Abc.focus condition gets overwritten by the second one in the $conditions array like Mariano suggested above. The simplest solution looks like below:
function aaa($focus_low, $focus_high) { $items = $this->Abc->findAll(array( 'Abc.users_id' => $this->Session->read('User.id'), 'Abc.focus >= '.$focus_low.' AND Abc.focus <= '.$focus_high ), null, 'startdate ASC'); } On Dec 14, 8:46 am, "gabordemeter" <[EMAIL PROTECTED]> wrote: > I have a problem with a findAll() query. The code is: > > $items = $this->Abc->findAll(array( > 'Abc.users_id' => $this->Session->read('User.id'), > 'Abc.focus' => ">= 3", > 'Abc.focus' => "<= 3" > ), null, 'startdate ASC'); > > What I want is to find those items which have focus = 3. But the code > above finds items which have focus <= 3. > > You may wonder why I don't not just use: 'Abc.focus' => "3"? > > Because this is part of a function: > > function aaa($focus_low, $focus_high) > { > $items = $this->Abc->findAll(array( > 'Abc.users_id' => $this->Session->read('User.id'), > 'Abc.focus' => ">= ".$focus_low, > 'Abc.focus' => "<= ".$focus_high > ), null, 'startdate ASC'); > > }So in some cases when I call this function i may want to find items > higher than or equal to 1 AND lower than or equal to 3. But in other > cases, like the above, i just want items which are equal to 3. > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---