条件构造类 Query
\EasySwoole\FastDb\Beans\Query 类用于构建在模型中使用构造查询、更新、删除等条件。
支持的方法有:
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
调用模型中的 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']);