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的時候還是會查出所有字段,然後再做的過濾。

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