A query array simply gets imploded with " AND " afaik.
In the example given it's not necessary to use an array but I use
arrays for just about every constraint. All that happens for the
previous example is the SubSql parameter is between WHERE and ORDER BY,
as you might expect.
For clarity (I hope) here is a much simpler example:
$Constraint = array();
if ($id) {
$Constraint["Comment.class"] = "blog";
$Constraint["Comment.foreign_id"] = $id;
}
list($order,$limit,$page) = $this->Comment->FindAll($Constraint);
Produces
SELECT ... FROM `comments` AS `Comment` WHERE (`Comment`.`class` =
'blog') AND (`Comment`.`foreign_id` = 1) ORDER BY `Comment`.`modified`
ASC, `Comment`.`id` ASC
but only if an id is passed. Much easier to handle optional/additional
constraints this way.
Cheers,
AD7six
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---