On Tue, Jun 16, 2009 at 8:40 AM, James K<[email protected]> wrote:
>
> If I understand correctly, you're running some finds to produce a
> giant array of user ids that match the conditions submitted by the
> user. THEN you're trying to take that list of user ids and pass them
> as a condition to a separate find to return the user details for each
> of those ids?
>
> First off, why not just pull all that information at once in a single
> find? Are you using the contain node in your find options to specify
> related models? You can specify conditions on the related models
> themselves in the contain.
>
> $this->User->find('all', array(
> 'contain' => array(
> 'UserDegree' => array(
> 'conditions' => array('UserDegree.degree_id' => array(2, 4,
> 6))
> )
> ),
> 'conditions' => array('User.age >' => 22, 'User.age <' => 27)
> )
>
Just to add to the advice from James, you could build up your
conditions array based on the submitted params. I would create a class
var something like:
var $search_models = array(
'degree' => 'UserDegree',
'cert' => 'Certification',
'skill' => Skill',
'lang' => Language',
belongsTo City'
);
The idea is that each available param points to a model name. You
could just pass the model name itself but, this way, you can ignore
any params that aren't listed here.
Anyway, you'd then check for any of these keys in your params and add
to the 'contain' part of your conditions array
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---