Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 调用未定义的方法/Database/Query/Builder::toArray()_Php_Mysql_Database_Laravel_Laravel Query Builder - Fatal编程技术网

Php 调用未定义的方法/Database/Query/Builder::toArray()

Php 调用未定义的方法/Database/Query/Builder::toArray(),php,mysql,database,laravel,laravel-query-builder,Php,Mysql,Database,Laravel,Laravel Query Builder,我是使用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)")

我是使用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();
首先获取()集合,然后将其转换为数组(toArray())

返回一个有说服力的查询生成器实例。这就像是
MySQL
query。它实际上不从数据库中获取数据

您需要执行该查询以从数据库中获取数据

这样做。调用
get()
函数到
雄辩的查询生成器实例

$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)")
    ->get()
    ->toArray();

将其更改为
->get()->toArray()put get(),我得到了如下错误{SQLSTATE[42000]:语法错误或访问冲突:1064您的SQL语法有错误;请查看与您的MariaDB服务器版本对应的手册,以了解在第1行的“SELECT UNIX_TIMESTAMP(Date(ts)*100作为ts)、sum(pot+p1pot+p2pot+p3pot+p4p)”附近使用的正确语法(SQL:选择select UNIX_TIMESTAMP(日期(ts)*100作为ts),sum(pot+p1pot+p2pot+p3pot+p4pot+p5pot+p6pot+p7pot+p8pot+p9pot)/count(*)作为EngineBooker的MoneyInput\u log.poker group by Date(ts)order by Date(ts)asc)}我输入get(),我得到了这样的错误{SQLSTATE[42000]:语法错误或访问冲突:1064您的SQL语法有错误;请查看与您的MariaDB服务器版本相对应的手册,以了解在第1行的“选择UNIX时间戳(日期(ts)*100作为ts)、sum(pot+p1pot+p2pot+p3pot+p4p)”附近使用的正确语法(SQL:选择选择UNIX时间戳(日期(ts)*100作为ts)、sum(pot+p1pot+p2pot+p3pot+p4pot+p5pot+p6pot+p7pot+p8pot+p9pot)/count(*)作为moneyInPlay from
enginepoker\u log
poker
groupby
Date(ts)
order by
Date(ts)
asc)}这是来自本机php$statsmoneinplay=array()的查询$sql\u query=“选择UNIX\u时间戳(日期(ts))*1000作为ts,求和(pot+p1pot+p2pot+p3pot+p4pot+p5pot+p6pot+p7pot+p8pot+p9pot)/count(*)作为EngineBooker\u log.poker中的MoneyPlay,其中dealId=“.$session->dealId.”按日期分组(ts)按日期排序(ts)限制30“$resource=sql::query($sql\u query)或者死(mysql_error());
$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)")
$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)")
    ->get()
    ->toArray();