我在控制器中声明了一个公共函数:
public function deaths()
{
$getdeaths = DB::statement('SELECT * FROM player_deaths ORDER BY time DESC LIMIT 10');
return View::make('main.latestdeaths')->with('getdeaths', $getdeaths);
}
然后我尝试检索数据:
<td>{{ $getdeaths->player_id }}</td>
但它不起作用。出现Trying to get property of non-object
错误。可以检索它吗?
答案 0 :(得分:0)
尝试
public function deaths()
{
$getdeaths = DB::select( DB::raw('SELECT * FROM player_deaths ORDER BY time DESC LIMIT 10') );
return View::make('main.latestdeaths')->with('getdeaths', $getdeaths);
}