【发布时间】:2018-10-02 03:37:03
【问题描述】:
我收到以下错误:
PHP 致命错误:无法在 C:\xampp\htdocs\enginepoker2\storage\framework\views\10cbbd076bede57a96e59c43af0e1b9e022b4a69.php 第 115 行中将 stdClass 类型的对象用作数组
查询生成器:
$statsMoneyInPlay = DB::table('enginepoker_log.poker')
->select(
DB::raw("UNIX_TIMESTAMP(Date(ts)*100) as timestamp"),
DB::raw("SUM(pot + p1pot + p2pot + p3pot + p4pot + p5pot + p6pot + p7pot + p8pot + p9pot) / count(*) As moneyInPlay")
)
->groupBy(DB::raw("DATE(ts)"))
->orderByRaw("DATE(ts)")
->get()
->toArray();
得到错误的刀片:
@php
foreach ($statsMoneyInPlay as $key => $value) {
echo "[".$value[0].", ".$value[1]."],";
}
@endphp
【问题讨论】:
-
使用 dd($statsMoneyInPlay); 时的输出是什么在那个查询生成器之后的控制器中?
-
请尝试将此对象转换为数组,$statsMoneyInPlay = (array) $statsMoneyInPlay;
标签: php mysql database laravel laravel-blade