Laravel查询未执行

时间:2013-08-17 11:10:31

标签: laravel laravel-4

我的视图中的查询未执行。来自->select('name')它只是在我的网站上显示为纯文本。

    <tbody>
    @foreach($getdeaths as $getdeath)
    <tr>
        <? DB::table('players')->select('name')->where('id', $getdeath->player_id)->get(); ?>
        <td>{{ $getdeath->player_id }}</td>
        <td>{{ $getdeath->level }}</td>
        <td>{{ date("d F Y (H:i)", strtotime($getdeath->time)) }}</td>
        <td>@if($getdeath->is_player == 1)
            {{ '<a href="characters/'.$getdeath->killed_by.'">'.$getdeath->killed_by.'</a> (PVP)' }}
            @else
            {{ $getdeath->killed_by }}
            @endif</td>
    </tr>
    @endforeach
</tbody>

1 个答案:

答案 0 :(得分:0)

更改

<? DB::table('players')->select('name')->where('id', $getdeath->player_id)->get(); ?>

<?= DB::table('players')->where('id', $getdeath->player_id)->pluck('name'); ?>

<?表示php

<?=表示php echo

您可以保存var并像平常一样回显它:

{{ $x=DB::table('players')->where('id', $getdeath->player_id)->pluck('name'); }}
{{ $x }}