條件構造類 Query
\EasySwoole\FastDb\Beans\Query
類用于構建在模型中使用構造查詢、更新、刪除等條件。
支持的方法有:
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
調用模型中的 queryLimit()
的返回值即為 \EasySwoole\FastDb\Beans\Query
類,方便開發者處理復雜的查詢條件。
查詢時示例
$user = new User();
$user->queryLimit()->where('name', 'easyswoole'); # 使用 Query 類的 where 方法
$userModel = $user->find();
echo $userModel->name;
更新時示例
$user = new User();
$user->queryLimit()->where('id', 1); # 使用 Query 類的 where 方法
$user->updateWithLimit(['name' => 'easyswoole']);