当我将 findby($id) 与关联条件一起使用时,我收到 SQL 错误:1054
我使用这个变量来查找与文章相关的评论。
$comment = $this->Article->Comment->findAllById($id);
当我添加这样的条件时,我收到错误。
$comment = $this->Article->Comment->findAllById($id,array('conditions' => array('Comment.status' => 1)));
我看到这个错误>>
Warning (512): SQL Error: 1054: Unknown column 'Comment.' in 'field list' [CORE\cake\libs\model\datasources\dbo_source.php, line 684]
Query: SELECT DISTINCT `Comment`.`` FROM `comments` AS `Comment` LEFT JOIN `articles` AS `Article` ON (`Comment`.`article_id` = `Article`.`id`) WHERE `Comment`.`id` = 15
i use this variable to find the comments that related with articles..
$comment = $this->Article->Comment->findAllById($id);
i get errors when i added conditons like this..
$comment = $this->Article->Comment->findAllById($id,array('conditions' => array('Comment.status' => 1)));
i see this error>>
Warning (512): SQL Error: 1054: Unknown column 'Comment.' in 'field list' [CORE\cake\libs\model\datasources\dbo_source.php, line 684]
Query: SELECT DISTINCT `Comment`.`` FROM `comments` AS `Comment` LEFT JOIN `articles` AS `Article` ON (`Comment`.`article_id` = `Article`.`id`) WHERE `Comment`.`id` = 15
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
查看 findAllBy
的手册field_name>()
方法。您会注意到第二个参数是一个
字段
数组。我建议使用 Cake 的标准查找方法,例如:
Take a look at the manual for the
findAllBy<field_name>()
method.You'll notice the second parameter is an array of
fields
.I would recommend using Cake's standard find method, something like: