What if you ask the question naming the Models and associations
between them, and what you were expecting to get back as the result of
the query. Finds and conditions depend greatly on the associations
between the models involded. Some use joins, most do not and all that.

SQL syntax also looks like a mess after google has messed with it.
Starting with a query and trying to duplicate it is usually more
complex than working from the Cake point of view... at least when
trying to build a find.

I am guesssing, but I think your main problem might be that Cake does
very few joins by default.
For example:
Post hasMany Comment - a find where you contain the comments to those
by a certain commenter will return ALL Posts and all will contain the
Comment key in the array. Contain will only make sure that some
Comment keys are empty and some have comments by that one commenter.

With a join you were expecting to only get the Post that actually have
Comments by that commenter. Not so with containable, sorry.

If you need to force Cake to do joins you can still paginate if you
build something like what Nate wrote about in january:
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find

I took some ideas from that and made a joining feature that would join
models for me when needed.
http://bin.cakephp.org/saved/49446

I have linked to these before but I think they are still valid
techniques in some cases.


Martin


On Aug 18, 12:08 pm, gjofum <[email protected]> wrote:
> I have no idea.
>
> I tried many things and nothing works.
> For exampple:
> $this->Item->find("all", array("fields" => array("Item.id",
> "Item.thumb"),
> "contain" => array(
>   "ItemContent" => array(
>           "conditions" => array("ItemContent.language_id" => 
> $this->language_id),
>
>           "fields" => array( "ItemContent.name",
> "ItemContent.description", "ItemContent.url")))
> ));
>
>  I'll have to use $this->Model->query() but then I won't be able to
> paginate it.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to