0

我在控制器中声明了一个公共函数:

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错误。是否可以检索它或?

4

1 回答 1

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);
}
于 2013-08-16T22:24:54.657 回答