Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两张桌子叫,product和productComment
product
productComment
产品表模型
productID userID productName
产品评论表模型
userID productID Comment
我有两个名为的虚拟字段comment1和comment2
comment1
comment2
当用户将此字段填写comment1为 2 时,comment2例如填写为 5。我想显示从 2 到 5 匹配的产品评论数。我该怎么做?
感谢您的帮助。
您需要添加group和having到您的查询条件。您没有显示您的关系定义,因此根据您的列/关系名称,您需要一些类似的东西
group
having
$criteria->group = 't.productID'; $criteria->having = 'COUNT(comment.commentID) > '.((int)$this->comment1). ' AND COUNT(comment.commentID) < '.((int)$this->comment2);