Hi
Why exactly do you want to "switch off the first query" ? Maybe you
could provide us with these queries you get, so that we can tell if
they really need to be "switched off" or not...
What you say about "two queries" with one retrieving all the data, and
the other "filtering" the previous ones result doesn't make sense at
all, to me. That's definitely not how "find" works, I've never seen it
act that way. And anyway, even from a SQL point of view, it doesn't
make sense (how can a query "filter" the results of a previous query
?).
Be more precise when you expose your problem, because we can't reply
something meaningful with so few informations...
Also, is "jobType" a field of the Contact model ? if so (just trying
guess), you should write your condition like this :
"conditions"=>array("Contact.jobType"=>"main")
It should do what you're trying to do...
Rather than asking two question at the same time, whereas they're not
really related to each other, you should split your problem in two
like : (1) try to get the data you want from the Model::find method,
and once you get how "find" works, (2) see if there actually is still
too many queries being done to the database, and provide us with more
debug data so we can have a small idea of why this happens...
+++++++
clément
On Sun, Aug 24, 2008 at 2:13 AM, eagle <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'm still struggling with a problem - which should be easy (I think)
> but .... :-( Any advice you more experienced folks could give ....?
>
> I want to achieve something akin to the following (building on the
> example in the manual):
>
> $this->Recipe->Ingredient->find('all');
>
> my code is
>
> $this->Venue->Contact->find('all',
> array('conditions'=>array('jobType'=>'main')));
>
> I am expecting this to retrieve data for venues and contacts where
> their jobtype is stated as 'main', but it fetches all venues and all
> contacts irrespective of their 'jobType'. I have tried replacing
> 'all' with 'first' but the same behaviour.
>
> The SQL debug info shows the Venue query running then TWO Contact
> queries - the first getting everything, the second filtering as I
> want .... how can I switch off the first CONTACT query ...?
>
> How can I get only the 'main' contacts for each venue and then display
> in a view?
>
> My latest fudge is to get them all and the filter in the view with:
> if ($contact['jobType'] == 'main') { ... }
> but I reckon I'm missing something much cleaner than this.
>
> Thanks for your help
>
> Eagle
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---