cakephp:使用计数器缓存进行排序
我有两个模型 下面的模型描述了它们之间的关系cakephp:使用计数器缓存进行排序,cakephp,cakephp-1.3,cakephp-1.2,Cakephp,Cakephp 1.3,Cakephp 1.2,我有两个模型 下面的模型描述了它们之间的关系 class DebatePost extends AppModel { var $name = 'DebatePost'; var $hasMany = array( 'DebateComment' => array( 'className' => 'DebateComment', 'foreignKey' => 'debate_id',
class DebatePost extends AppModel {
var $name = 'DebatePost';
var $hasMany = array(
'DebateComment' => array(
'className' => 'DebateComment',
'foreignKey' => 'debate_id',
'dependent'=> true,
)
);
}
class DebateComment extends AppModel {
var $name = 'DebateComment';
var $belongsTo = array(
'DebatePost' => array(
'className' => 'DebatePost',
'foreignKey' => 'debate_id',
'dependent' => true,
'counterCache' => 'no_of_comments'
)
);
}
我在辩论帖子表中创建了“无评论”字段
及
在DebatPost控制器中
$arrde = $this->DebatePost->find('all',array('order'=>'debat_posts.no_of_comments DESC'));
我遵循上面的第二步,通过使用countercache,find Difference_发布数据orderby no of comments in Difference_comments,但没有得到任何结果
'order'=>'DebatePost.no_of_comments DESC'