Changes between Version 3 and Version 4 of ApplyingCustomJoinsInDoSelect
- Timestamp:
- 06/12/06 16:00:14 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ApplyingCustomJoinsInDoSelect
v3 v4 1 1 == Applying custom joins in doSelect* method == 2 2 3 You want to join a table when running doSelect method to save you from doing multiple queries . If for various reasons you cannot refer it to a foreign key column, you can still write your own {{{doSelectJoin*}}} method like the code generated by Propel. This page describes how to achieve this.3 You want to join a table when running doSelect method to save you from doing multiple queries, but for various reasons you cannot refer it to a foreign key column in the schema, so propel doesn't generate the code for you. This page describes how to still write your own {{{doSelectJoin*}}} method like the code generated by Propel. 4 4 5 5 Say you want to join {{{Article}}} with {{{Book}}} then join with {{{Category}}}, with {{{article.book_id = book.id AND book.category_id = category.id}}}. 134 134 That's it! You can use {{{ArticlePeer::doSelectJoinBookAndCategory()}}} to fetch the books also with the book and category fields. Calling {{{$article->getBook()}}} and {{{$article->getCategory()}}} won't cause an extra query. To use this function in a pager, call {{{$pager->setPeerMethod('doSelectJoinBookAndCategory');}}}. Note that you can use the ordinal doCount for the above example. However if you are doing something that affects the result count (like grouping, or joinging that causes some rows not fetched) in the {{{doSelect*}}} method, you will have to roll your own {{{doCount*}}} method and call {{{$pager->setPeerMethod('doCountJoinBookAndCategory');}}} to ensure proper count. 135 135 136