鍍金池/ 問(wèn)答/PHP/ Laravel 使用eloquent 中的orderBy將會(huì)報(bào)錯(cuò)

Laravel 使用eloquent 中的orderBy將會(huì)報(bào)錯(cuò)

$datum = Coupon::orderBy('create_at','desc')->get();
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'orders by `create_at` desc' at line 1 (SQL: select * from `st_coupon` where `st_coupon`.`delete_at` is null orders by `create_at` desc)

laravel 5.6版本 php 7.2

就是數(shù)據(jù)庫(kù)操作將orderBy編譯成了orders by,是什么原因?

回答
編輯回答
你好胸

我問(wèn)倆個(gè)問(wèn)題:
1.created_at是不是created_at?
2.sqlwhere語(yǔ)句是從哪里來(lái)的,是不是代碼沒(méi)貼完整

2017年8月7日 13:42