2020-11-23 15:29:17 1121次浏览 0条回答 0 悬赏 10 金钱

xunsearch 在 Yii2 中使用,如何开启模糊匹配?

public function getSearchData($keyword, $selectType, $pageSize = 10, $offset = 0)
{
    $query = XunSearchModel::find()->where($keyword)->andWhere(['status' => 0]);
    if ($selectType) {
        $query->andWhere(['type' => $selectType]);
    }

    $count = $query->count();
    $pages = new Pagination([
        'totalCount' => $count,
        'page'       => Yii::$app->request->get('page', 1) - 1,
        'pageSize'   => $pageSize
    ]);

    $data = $query->offset($offset ?: $pages->offset)
        ->limit($pages->limit)
        ->all();

    $result['count'] = $count;

    return $result;
}
    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
PHP学院的中学生
副总裁

PHP学院的中学生

注册时间:2018-10-23
最后登录:2024-04-07
在线时长:168小时1分
  • 粉丝29
  • 金钱4730
  • 威望30
  • 积分6710

热门问题