Here's an example...
I'm using a table to manage all of my Statuses with the tree behavio开发者_开发技巧r. I have a Book model which has a status for it's condition and one for it's availability. So the Book model HABTM Statuses even thought it can only have one condition and one availability.
Is there a way to use the $paginator->sort('Condition', '?') with a HABTM ? I would like to sort the title from the array below.
This is what $this->data is giving me :
[Status] => Array
(
[0] => Array
(
[id] => 2
[parent_id] => 1
[lft] => 2
[rght] => 3
[title] => Mint
[created] => 2010-01-18 16:20:54
[modified] => 2010-01-18 16:20:54
[active] => 1
[BooksStatus] => Array
(
[id] => 7
[book_id] => 3
[status_id] => 2
)
)
)
i would use 2 x belongsTo with different names.
$belongsTo = array(
'BookStatus' => array(
'className' => 'Status',
'foreignKey' => 'book_status_id'
),
'BookCondition' => array(
'className' => 'Status',
'foreignKey' => 'book_condition_id'
)
)
dont know how this would then fit into your tree strut
if that doesnt work then Try $paginator->sort('Condition', 'BooksStatus.status_id'); you will need to make sure the query used to retrieve the above does a join(unBind/bind on the fly)
精彩评论