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