belongsTo('app\\common\\model\\user\\Tag', 'tag_id', 'tag_id'); } public static function getListByUser($user_id){ $model = new self; return $model->alias('user_tag')->field(['user_tag.*,tag.tag_name']) ->join('tag', 'tag.tag_id = user_tag.tag_id', 'left') ->where('user_tag.user_id', '=', $user_id) ->order(['user_tag.create_time' => 'asc']) ->select(); } public static function getCountByTag($tag_id){ $model = new self; return $model->where('tag_id', '=', $tag_id) ->count(); } }