Monday, November 2, 2009

Re: Cake and PHP5/PHP6, Base URL in Controllers and FIND QUERY with OR

On 2 nov, 12:47, "Prof. No Time" <libertylivingst...@gmail.com> wrote:
> Thanks so so much AD7six,
>
> Your suggestion of Router::url() worked like magic but for the second
> suggestion on the query, I tried it and the debug dump gave me this:
>
> SELECT `AppSetting`.`id`, `AppSetting`.`name`, `AppSetting`.`value`,
> `AppSetting`.`created`, `AppSetting`.`modified` FROM `app_settings` AS
> `AppSetting` WHERE `AppSetting`.`name` IN ('EMAIL_HEADER_HTML',
> 'EMAIL_FOOTER_HTML', 'EMAIL_HEADER_TEXT', 'EMAIL_FOOTER_TEXT')
>
> As you can see from above, it generates to an IN SQL query, I do not
> want an IN SQL query what I want is this:
>
> SELECT `AppSetting`.`id`, `AppSetting`.`name`, `AppSetting`.`value`,
> `AppSetting`.`created`, `AppSetting`.`modified` FROM `app_settings` AS
> `AppSetting`
> (WHERE `AppSetting`.`name` = 'EMAIL_HEADER_HTML' OR
> `AppSetting`.`name` = 'EMAIL_FOOTER_HTML' OR `AppSetting`.`name` =
> 'EMAIL_HEADER_TEXT' OR `AppSetting`.`name` = 'EMAIL_FOOTER_TEXT')
>
> Please how do I write the "find()" syntax to achieve this? Or am I
> missing a point here?

I think so,

> Is the 'IN' syntax equivalent (100%) to the 'OR'
> syntax I desire?

Well,
samefield = x OR samefield = y
is the same as
samefield IN (x, y)

There are times that won't work, but they aren't relevant to your
example. E.g.:
$conditions = array(
'OR' => array(
'samefield' => 0,
array('samefield' => null)
)
)

hth,

AD
--~--~---------~--~----~------------~-------~--~----~
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: