easy_swoole获取指定的列

获取指定的列,并且设置某些列的别名:
swoole 4.5,easy_swoole 3.x

public function getUserInfo($id)
{
    $user = UserModel::field(['id as user_id', 'nickname', 'avatar', 'country_code', 'telephone', 'email', 'language', 'xxx', 'xx'])
        ->get($id);
    return $user;
}

注意:field方法一定要在get之前调用,不然查询sql的时候还是会查出所有字段,然后再做的过滤。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章