First of all the way you are defining the conditions make use of an indexed
array, so beware of overwriting the same index. Why don't you just break it
down like:

function aaa($focus_low, $focus_high)
{
        $conditions = array (
                'Abc.users_id' => $this->Session->read('User.id'),
        );

        if ($focus_low == $focus_height)
        {
                $conditions['Abc.focus'] = $focus_low;
        }
        else
        {
                $conditions[] = array ('Abc.focus' => ">= ".$focus_low);
                $conditions[] = array ('Abc.focus' => "<= ".$focus_high);
        }

        $items = $this->Abc->findAll($conditions, null, 'startdate ASC');

        return $items;
}

Try that, I haven't tested it. If it doesn't work (that is, the expression
after previous else) try:

else
{
        $conditions = 'Abc.users_id = ' . $this->Session->read('User.id');
        $conditions .= ' AND ';
        $conditions .= 'Abc.focus >= ' . $focus_low;
        $conditions .= ' AND ';
        $conditions .= 'Abc.focus <= ' . $focus_high;
}

-MI

---------------------------------------------------------------------------

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!


-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de gabordemeter
Enviado el: Jueves, 14 de Diciembre de 2006 10:47 a.m.
Para: Cake PHP
Asunto: findAll query problem - mutiple conditions for one field not
executing

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.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to