在cakephp3中重写SQL?

时间:2016-09-19 10:37:44

标签: cakephp-3.0

这是我对MySQL的查询:

select u.full_name, c.comment_content from users u, comments  WHERE u.user_id=c.user_id 

如何在cakephp中使用find()重写此SQL?

1 个答案:

答案 0 :(得分:0)

你走了:

$query = $this->Users
    ->find()
    ->select(['full_name', 'comment_content'])
    ->where(['user_id =' => $cUserID])
    ->order(['created' => 'DESC']); //extra

http://book.cakephp.org/3.0/en/orm/query-builder.html