From 43318c7c0e6e543f1789ebd277c727bdf24b0c97 Mon Sep 17 00:00:00 2001 From: DavidBadura Date: Mon, 6 Apr 2015 22:03:22 +0000 Subject: [PATCH] add more query builder features --- README.md | 9 +++++++ src/QueryBuilder.php | 64 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/README.md b/README.md index 636755f..43e3104 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,12 @@ $tasks = $tm->filter('project:hobby'); // empty ## API todo... + +### QueryBuilder + +```php +$tasks = $taskManager->createQueryBuilder() + ->whereProject('hobby') + ->sortBy(QueryBuilder::SORT_ENTRY) + ->getResult() +``` \ No newline at end of file diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index ac8a00f..b1b356b 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -63,6 +63,30 @@ class QueryBuilder return $this->where('priority:' . $priority); } + /** + * @return $this + */ + public function wherePriorityL() + { + return $this->wherePriority(Task::PRIORITY_LOW); + } + + /** + * @return $this + */ + public function wherePriorityM() + { + return $this->wherePriority(Task::PRIORITY_MEDIUM); + } + + /** + * @return $this + */ + public function wherePriorityH() + { + return $this->wherePriority(Task::PRIORITY_HIGH); + } + /** * @param string $status * @return $this @@ -72,6 +96,46 @@ class QueryBuilder return $this->where('status:' . $status); } + /** + * @return $this + */ + public function wherePending() + { + return $this->whereStatus(Task::STATUS_PENDING); + } + + /** + * @return $this + */ + public function whereWaiting() + { + return $this->whereStatus(Task::STATUS_WAITING); + } + + /** + * @return $this + */ + public function whereCompleted() + { + return $this->whereStatus(Task::STATUS_COMPLETED); + } + + /** + * @return $this + */ + public function whereRecurring() + { + return $this->whereStatus(Task::STATUS_RECURRING); + } + + /** + * @return $this + */ + public function whereDeleted() + { + return $this->whereStatus(Task::STATUS_DELETED); + } + /** * @param string $where * @return $this