【发布时间】:2017-10-09 19:17:14
【问题描述】:
我有这样的查询
SELECT area FROM history_cost_estimation ORDER BY CAST(REPLACE(area, ' ', '') AS INT)
我正在尝试将此类查询转换为 laravel 查询生成器,但我遇到了很多错误
这是我的尝试
App\Models\HistoryCostEstimation::orderBy("CAST(REPLACE(area, ' ', '') AS INT)",'asc')->count();
这里是错误示例
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'as `)` asc' at line 1 (SQL: select count(*) as aggregate from `engineertec`.`history_cost_estimation` order by `CAST(REPLACE(area,` as `)` asc)
【问题讨论】:
标签: laravel laravel-5 eloquent laravel-eloquent laravel-query-builder