Hi there,
I have a problem I can't solve. I need to build up this query
SELECT `Runner`.`id`, `Runner`.`name`, `Runner`.`surname`,
`Runner`.`nationality` FROM `runners` AS `Runner` WHERE
((`Runner`.`name` LIKE '%mark%') OR (`Runner`.`surname` LIKE '%mark
%')) AND `Runner`.`id` IN (SELECT runner_id from runners_teams where
year = 2008)
but using the function findAll with arrays I find it difficult to
create this query. The only result I can get is:
SELECT `Runner`.`id`, `Runner`.`name`, `Runner`.`surname`,
`Runner`.`nationality` FROM `runners` AS `Runner` WHERE
((`Runner`.`name` LIKE '%mark%') OR (`Runner`.`surname` LIKE '%mark
%')) AND `Runner`.`id` IN ('SELECT runner_id from runners_teams where
year = 2008')
(notice the single quotes in the nested query starting with IN. This
is the reason why it doesn't work. Infact, if I paste the query
without quotes in mysql everything runs smooth.
This is the code I used to implement such (broken) query:
$query = array("OR" => array(
"Runner.name" => "LIKE
%".$runner['name']."%",
"Runner.surname" => "LIKE %" .
$runner['name'] . "%"),
"Runner.id" => array("SELECT runner_id from
runners_teams
where year = 2008"));
and then I call a findAll($query);
Thanks for your help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---