【发布时间】:2019-03-06 04:11:15
【问题描述】:
我是使用 laravel 的新手,我收到这样的错误:
Call to undefined method Illuminate\Database\Query\Builder::toArray()
这是 laravel 中的查询生成器
$statsMoneyInPlay = DB::table('enginepoker_log.poker')
->selectRaw("SELECT UNIX_TIMESTAMP(Date(ts)*100 as ts)")
->selectRaw("sum(pot + p1pot + p2pot + p3pot + p4pot + p5pot + p6pot + p7pot + p8pot + p9pot) / count(*) As moneyInPlay")
->groupBy("Date(ts)")
->orderBy("Date(ts)")
->toArray();
【问题讨论】:
-
改成
->get()->toArray(); -
put get() 我得到了这样的错误 { SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的 'SELECT UNIX_TIMESTAMP(Date(ts)*100 as ts)、sum(pot + p1pot + p2pot + p3pot + p4p' 附近使用正确的语法(SQL:选择SELECT UNIX_TIMESTAMP(Date(ts)*100 as ts), sum(pot + p1pot + p2pot + p3pot + p4pot + p5pot + p6pot + p7pot + p8pot + p9pot) / count(*) As moneyInPlay from enginepoker_log.poker group by Date( ts) 按日期排序 asc) }
标签: php mysql database laravel laravel-query-builder