條件構(gòu)造類(lèi) Query
\EasySwoole\FastDb\Beans\Query
類(lèi)用于構(gòu)建在模型中使用構(gòu)造查詢(xún)、更新、刪除等條件。
支持的方法有:
limit(int $num,bool $withTotalCount = false):Query
page(?int $page,bool $withTotalCount = false,int $pageSize = 10):Query
fields(?array $fields = null,bool $returnAsArray = false):Query
hideFields(array|string $hideFields):Query
getHideFields():?array
getFields():?array
orderBy($orderByField, $orderbyDirection = "DESC", $customFieldsOrRegExp = null):Query
where(string $col, mixed $whereValue, $operator = '=', $cond = 'AND'):Query
orWhere(string $col, mixed $whereValue, $operator = '='):Query
join($joinTable, $joinCondition, $joinType = ''):Query
func(callable $func):Query
returnEntity():AbstractEntity
調(diào)用模型中的 queryLimit()
的返回值即為 \EasySwoole\FastDb\Beans\Query
類(lèi),方便開(kāi)發(fā)者處理復(fù)雜的查詢(xún)條件。
查詢(xún)時(shí)示例
$user = new User();
$user->queryLimit()->where('name', 'easyswoole'); # 使用 Query 類(lèi)的 where 方法
$userModel = $user->find();
echo $userModel->name;
更新時(shí)示例
$user = new User();
$user->queryLimit()->where('id', 1); # 使用 Query 類(lèi)的 where 方法
$user->updateWithLimit(['name' => 'easyswoole']);