copyright/app/common/repository/FictionLibraryRepository.php
2023-02-07 13:32:03 +08:00

22 lines
545 B
PHP

<?php
namespace app\common\repository;
use app\common\model\FictionLibraryModel;
class FictionLibraryRepository extends FictionLibraryModel
{
public function selectAll(array $fields, int $page, int $limit, string $keyword):array
{
$where = [];
$orWhere = [];
if (!empty($keyword)) {
$where[] = ['work_name', 'like', '%' . $keyword . '%'];
$orWhere[] = ['reg_number', 'like', '%' . $keyword . '%'];
}
return FictionLibraryModel::where($where)->orWhere($orWhere)->offset($page)->limit($limit)->get($fields)->toArray();
}
}