所以,我想对我的一个请求进行分页。“正常方式”似乎效果不佳,所以,我做了一些研究,所有的答案都告诉你要做这样的事情:
$this->paginate("Like",
array("Like.user_id" => $id),
array(
"order" => "Like.created desc",
"contain" => array(
"User",
"Post",
"Post.User",
"Post.Like"
)
)
);
问题是……它不起作用。Adebug
给了我类似的东西:
array(
(int) 0 => array(
'Like' => array(
'id' => '38',
'created' => '2012-10-03 21:21:27',
'post_id' => '29',
'user_id' => '19'
),
'Post' => array(
'id' => '29',
'title' => 'Don't Panic',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam elementum sem ac sem imperdiet cursus. Quisque venenatis pulvinar ornare. Donec rutrum, lacus vel imperdiet sagittis, metus risus interdum ante, iaculis venenatis arcu nibh et odio.',
'image' => '29-c49cb96c.jpg',
'model' => '',
'created' => '2012-09-07 01:46:49',
'user_id' => '19',
'project_id' => '1',
'like_count' => '1'
),
'User' => array(
'password' => '*****',
'id' => '19',
'username' => 'Axiol'
)
)
)
没有痕迹Post.User
和Post.Like
...
任何想法 ?
编辑:
以下是模型关联:
邮政
public $belongsTo = array("User", "Project");
public $hasMany = array("Comment", "Like");
喜欢
public $belongsTo = array("User", "Post" => array("counterCache" => true));
用户
public $hasMany = array("Post", "Comment");