22 lines
545 B
PHP
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();
|
|
}
|
|
}
|