Friday, August 27, 2010

Complex find

I need to translate this query into a find() statement

select id, `encounterStartTimeStamp`, `entryReason_id` from
`encounters` where encounterStartTimeStamp >= '2010-08-26' and
`encounters`.`entryReason_id` in (SELECT `entryReasons`.`ID` FROM
`entryReasons` WHERE `ReasonName` LIKE "SUB%")

I have looked over the docs for the find function and i see the
example of using an array to run the SELECT IN: array( "Post.title"
=> array("First post", "Second post", "Third post")) But since my
SELECT IN is a query its self im not sure on how to proceed. I have
tried:

$conditions = array('Encounter.encounterStartTimeStamp >=' =>
'2010-08-26',
'Encounter.entryReason_id' => 'SELECT
`entryReasons`.`ID` FROM `entryReasons` WHERE `ReasonName` LIKE "SUB
%"');

Im kinda lost here.. any help would be appreciated

thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: