1
爲什麼沒有工作按「作者」排序?不會引發任何錯誤,只是未排序使用加入cakephp排序問題
function index()
{
$this->paginate = array(
'limit' => 5,
'order' => array(
'Post.id' => 'asc',
),
'fields' => array('Post.id', 'Post.title', 'User.name AS aut_name'),
'joins' => array(
array(
'table' =>'users',
'alias' =>'User',
'type' =>'LEFT',
'conditions' => array(
'Post.author = User.id'
)
)
)
);
$posts = $this->paginate();
$this->set('posts', $posts);
}
<tr>
<th><?php echo $paginator->sort('ID', 'id'); ?></th>
<th><?php echo $paginator->sort('Author', 'User.name'); ?></th>
<th><?php echo $paginator->sort('Tilte', 'title'); ?></th>
<th>Actions</th>
</tr>
您的代碼表示,它的排序由Post.id,不是作者 – chustar 2011-01-29 21:08:40
但當我點擊「