You are welcome :)

I just have a lot of HABTM relationships, but I have no wish to define
all these joins. It is kind of non-object oriented solution, that the
controller needs to know how to define relationships/joins for
pagination.

My change to Containable mostly ensures that I can make conditions on
HABTM related tables without having the need to present their content.
And that is what I require most.

Wish you luck, enjoy,
   John

On Jan 13, 9:13 pm, thomaus <tho...@saimiris.com> wrote:
> Thanks for your help. You method perfectly works (unless the OR
> condition with pagination filters) but I think the smartest way (and
> simpliest way) to do is the one I found in this 
> blog:http://cakebaker.42dh.com/2007/10/17/pagination-of-data-from-a-habtm-...
>
> But still, Cake should let the include pagination with
> hasAndBelongsToMany.
>
> Thanks again!
>
> On Jan 12, 8:29 pm, John Andersen <j.andersen...@gmail.com> wrote:
>
> > Hej Thomaus,
>
> > I have a modified Containable behaviour, that may help you solve your
> > problem.
>
> > Find it herehttp://bin.cakephp.org/view/763226357andplace it in
> > your app/models/behaviours directory, it will then replace the CakePHP
> > Containable behaviour.
>
> > I can now make finds that looks like:
> > [code]
> >       $rows = $this->find(
> >          'all', array(
> >             'contain' => array('Author'),
> >             'conditions' => array('Collection.name' => 'recent'),
> >             'order' => array('Article.created' => 'DESC')
> >          )
> >       );
> > [/code]
>
> > The above will find all Article with their Author, for which it
> > applies that the article is included in the Collection with the name
> > "recent"
>
> > The models are related as:
> > Author hasMany Article / Article belongsTo Author
> > Article hasAndBelongsToMany Collection & reverse
>
> > The change to Containable takes the Collection model in the condition
> > and makes an INNER JOIN through the join table and an INNER JOIN with
> > the collections table.
>
> > The final SQL statement looks as:
> > [code]
> > SELECT `Article`.`id`, `Article`.`title`, ..., `Author`.`id`,
> > `Author`.`name`, ...
> > FROM `articles` AS `Article`
> > INNER JOIN articles_collections AS `ArticlesCollection` ON
> > (`ArticlesCollection`.`article_id` = `Article`.`id`)
> > INNER JOIN collections AS `Collection` ON (`Collection`.`id` =
> > `ArticlesCollection`.`collection_id`)
> > LEFT JOIN `authors` AS `Author` ON (`Article`.`author_id` =
> > `Author`.`id`)
> > WHERE `Collection`.`name` = 'recent' ORDER BY `Article`.`created` DESC
> > [/code]
>
> > I have tried it with Paginate and it is Paginate friendly :)
>
> > If you can use it, take it and have fun :)
> > Enjoy,
> >    John
>
> > On Jan 12, 8:30 pm, thomaus <tho...@saimiris.com> wrote:
>
> > > I can't believe there are no solution to this problem. I mean, it's
> > > just paginating a model with a second order filter!
>
> > > HELP! HELP! HELP! This is urgent!
>
> > > On Jan 11, 8:50 am, Fran Iglesias <cakephpi...@gmail.com> wrote:
>
> > > > Hi,
> > > > El 11/01/2010, a las 8:35, Jeremy Burns escribió:
>
> > > > > I have had the very same annoying problem and couldn't solve it. I  
> > > > > wanted to do (effectively - using the good old blog as an example):
>
> > > > If you are writing your custom find types to perform the search as in
>
> > > >http://rafaelbandeira3.wordpress.com/2008/08/28/the-new-way-to-define...
>
> > > > you could try this sort of hack:
>
> > > >http://code.assembla.com/milhojas/subversion/nodes/app_model.php?rev=394
>
> > > > (I override the method in the app_model to avoid touch the core).
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to