Thursday, November 27, 2008

Re: custom find conditions

You can't define the same key twice in an array - 'AND' in your case.

Try this:

'conditions' => array(
'or' => array(
array(
'ceg_id' => 0, 'osztaly_id' => $osztalyok
),
array(
'ceg_id' => 1, 'osztaly_id' => 0
)
)
)

hth
grigri

On Nov 27, 5:19 pm, "rrd...@gmail.com" <rrd...@gmail.com> wrote:
> Hari,
>
> I need the following SQL query but can't get it by the array syntax.
> SELECT * FROM table
> WHERE (
> (ceg_id = 0 AND osztaly_id IN(1,2))
> OR
> (ceg_id = 1 AND osztaly_id = 0)
> )
>
> I tried many different forms like this for find('all')
> 'conditions' => array(
> 'szamla_id' => $szamlaId,
> 'AND' => array(
> 'OR' => array(
> 'AND' => array(
> 'ceg_id' => 0,
> 'osztaly_id' => $osztalyok
> ),
> 'AND' => array(
> 'ceg_id' => 1,
> 'osztaly_id' => 0
> )
> )
> )

On Nov 27, 5:19 pm, "rrd...@gmail.com" <rrd...@gmail.com> wrote:
> Hari,
>
> I need the following SQL query but can't get it by the array syntax.
> SELECT * FROM table
> WHERE (
>    (ceg_id = 0 AND osztaly_id IN(1,2))
>    OR
>    (ceg_id = 1 AND osztaly_id = 0)
> )
>
> I tried many different forms like this for find('all')
> 'conditions' => array(
>    'szamla_id' => $szamlaId,
>    'AND' => array(
>       'OR' => array(
>          'AND' => array(
>             'ceg_id' => 0,
>             'osztaly_id' => $osztalyok
>           ),
>          'AND' => array(
>             'ceg_id' => 1,
>             'osztaly_id' => 0
>          )
>       )
>    )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: