The problem here is that you need to force a join so that the field
you want to sort the results by is included in the main query.
Containable alone will not help as it will not force a join for you.
Take a look at find's JOIN options
http://book.cakephp.org/view/872/Joining-tables
it should get
Try using Containable, it may help you:
http://book.cakephp.org/view/1323/Containable
Try doing something like: $this->Category->find('all', array('contain' =>
array('Post' => array('order' => 'CategoriesPost.postorder';
On Sat, May 15, 2010 at 1:25 PM, ashok.b wrote:
> If I add a order col
If I add a order column in Posts, then I won't be able to order the
posts per category... What ever order I set to a post will be
applicable across all categories that post is linked to... I'm looking
for per category ordering of posts.
On May 15, 8:55 am, Bogdan Bursuc wrote:
> Add in your Post
Didn't work :(
More over, $this->Post->find('all') starts throwing an SQL error
'CategoriesPost.postorder' not found...
On May 15, 8:55 am, Bogdan Bursuc wrote:
> Add in your Post Model
>
> class Post extends AppModel {
> var $order = 'CategoriesPost.postorder';
>
> }
>
> Anyway I wouldn't
Add in your Post Model
class Post extends AppModel {
var $order = 'CategoriesPost.postorder';
}
Anyway I wouldn't do it like so. I would just add an order field on the Post
model. It's easier.
On Sat, May 15, 2010 at 1:24 AM, ashok.b wrote:
>
>
> Hello Cake Gurus, here's my problem:
>
> T
Hello Cake Gurus, here's my problem:
Table1: Posts
id - int
title - varchar
Table2: Categories
id - int
name - varchar
HABTM JoinTable: categories_posts
id - int
post_id - int
category_id - int
postorder - int
As you can see, the join table contains a field called 'postorder' -
This is for