laravel数据表CPU使用情况

时间:2016-06-16 11:03:28

标签: php laravel

这是我的控制器:

public function anyData()
{
    $myID = Auth::guard('cashier')->user()->id;


    $players = User::where('parent_id','=', $myID)
        ->where('delete', '=', 1)
        ->orderBy(DB::raw('LENGTH(name),name'))
        ->get(['id', 'name', 'score', 'alarm', 'bonus_from_percentage']);


    return Datatables::of($players)

        ->addColumn('actions4', function ($players) {
            return
                '
                <a href="#" data-id="'.$players->id.'" data-name="'.$players->name.'" data-target="#actions-modal"  class="open-playerID btn btn-warning" data-toggle="modal"
                       data-target="#actions-modal" data-toggle="tooltip" data-placement="top" title="'.trans('cashier.SETTINGS').'"><span class="glyphicon glyphicon-cog"></span></a>
                ';
        })
        ->addColumn('actions3', function ($players) {
            return
                '
                <button type="button" class="'.changeClass($players->alarm).'"
                     value="OK" onclick="Enable('.$players->id.','.$players->alarm.')" id="enable"/><span class="glyphicon glyphicon-ok-circle"></span></button>
                ';
        })
        ->addColumn('actions2', function ($players) {
            return
            '
            <a href="#" data-toggle="modal" data-id="'.$players->id.'" data-target="#changeplayerpassword-modal" data-toggle="tooltip" data-placement="top" title="'.trans('cashier.CHANGEPLAYERPASS').'" class="playeridchangepass btn btn-warning">
            <span class="glyphicon glyphicon-edit"></span></a>

                <a href="#" data-id="'.$players->id.'" data-name="'.$players->name.'"  data-target="#delete-modal" class="open-delete btn btn-warning" data-toggle="modal"
                       data-target="#delete-modal"  data-toggle="tooltip" data-placement="top" title="'.trans('cashier.DELETE').'" ><span class="glyphicon glyphicon-remove"></span></a>
                ';
        })
        ->addColumn('actions', function ($players) {
            return
                '<div class="btn-group text-center">
            <button onclick="changeValueIn(this);" class="btn btn-primary btn-sm" style="width: 50px;"  data-score-id="' . AppHelper::ToEuroC($players->score) . '" data-player-id="' . $players->id . '" data-name-id="' . $players->name . '"  data-toggle="modal" data-target="#In">IN</button>
            <button onclick="changeValue(this)"class="btn btn-danger btn-sm"  data-score-id="' . AppHelper::ToEuroC($players->score) . '"data-player-id="' . $players->id . '" data-name-id="' . $players->name . '" data-toggle="modal" data-target="#Out">OUT</button>
            </div>
            ';
        })
        ->addColumn('score', function ($players) {
            return AppHelper::ToEuroC($players->score);
        })
        ->addColumn('bonus_from_percentage', function ($players) {
            return AppHelper::ToEuroC($players->bonus_from_percentage);
        })
        ->addColumn('players', function ($players) {
            return ($players->name) . ' ' .dikOn($players->id);
        })
        ->make(true);
}

这个脚本每5秒运行一次刷新表:

// REFRESH TABLE
function refreshptable() {
    if (table != null)
        table.ajax.reload(null, false);
    setTimeout(refreshplayers
            , 5000);
}

我在服务器上传了我的laravel项目(我在线有大约300名用户) CPU负载为200 +

在我的旧PHP代码(No Laravel)上,CPU负载为10-15 它有什么问题的数据表或laravel?  我检查请求是否相同没有循环和所有查询相同唯一的区别是laravel ..

在TOP -C laravel使用3%我的旧代码使用0.3%..

0 个答案:

没有答案