tp5 模型查询构建器问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hjh15827475896/article/details/85256445

情况,在product 模型中倒序查出前二十条最近的信息

在 模型中定义方法

public function getRecent($limit){

        return $this->order("id","desc")->limit($limit)->select();

}

这种方式报错 property not exists:app\\api\\model\\Product->id  

打印出 sql 的样子是   

SELECT * FROM `order` LIMIT 20

又改写

return $this->limit($limit)->order("id","desc")->select();

SELECT * FROM `product` ORDER BY `id` DESC LIMIT 20

正确返回结果

这难道是说 tp5 的 order 不能用在 limit前面????

猜你喜欢

转载自blog.csdn.net/hjh15827475896/article/details/85256445
今日推荐