http://foldifoldi.com/news/?p=466
On Dec 25, 9:15 am, foldiman <vi...@vinceallen.com> wrote:
> Andrew,
> It sounds like you want to use a join in yourpaginationquery. If you
> have set up your model relationships, the joins may happen
> automagically. However, you can force the join using the 'joins'
> parameter in thepaginationquery. For example:
>
> $joins1 = array(
> 'table' => 'bug_relations',
> 'alias' => 'BugRel',
> 'type' => 'inner',
> 'foreignKey' => false,
> 'conditions' => array(
> 'BugsGarden.bug_relation_id = BugRel.id',
> 'BugRel.name LIKE' => '%' . 'beetle' . '%'
> )
>
> $this->paginate= array(
> 'BugsGarden' => array(
> 'limit' => 20,
> 'order' => array('BugsGarden.created' => 'asc'),
> 'contain' => array(
> 'Garden', 'BugRelation'
> ),
> 'joins' => array($joins1)
> )
> )
>
> If you wanted to see what Bugs were found in which
> Garden...specifically which bugs have the string 'beetle' in their
> name, you could paginate a relation table that carries which bugs are
> in which garden using ids as foreign keys. You can then get the name
> from another table....in this example a table called 'bug_relations'
> that carries info about the various bugs. The join to get the full
> names or other info is forced in the 'joins' param of thepagination
> query. Remember to include the table name in your sort keys.
>
> An example of cross database queries is also here.
>
> http://foldifoldi.com/news/?p=436
>
> I hope this helps,
> Vince
>
> On Dec 24, 12:32 pm, Andrew <and...@websitesthatdostuff.com> wrote:
>
>
>
> > Greetings, all,
> > I know other people have worked on this before, but I haven't
> > been able to find a solution so far. So, the long and short of it is
> > that I've got multiple models that I want to mix into one view sorted
> > by the date created.
>
> > I've got a 'created' datetime field in the database already. I
> > understand how to paginate each of the individual database calls and
> > merging that info together, but that doesn't work with the core
> >paginationstuff as I understand it. Do you have any suggestions for
> > developing this?
>
> > Also, I'd like to keep the number of database calls down, so any
> > suggestions along those lines would be great. Thanks!
>
> > ~Andrew
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment