This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from filebase/1.0
sync 01
- Loading branch information
Showing
4 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,6 @@ if ($database->has('kingslayer')) | |
// do some action | ||
} | ||
|
||
|
||
// Need to find all the users that have a tag for "php" ? | ||
$users = $db->query()->where('tags','IN','php')->results(); | ||
|
||
|
@@ -379,13 +378,16 @@ echo $user['name']; | |
// What about regex search? Finds emails within a field | ||
$users = $db->query()->where('email','REGEX','/[a-z\d._%+-]+@[a-z\d.-]+\.[a-z]{2,4}\b/i')->results(); | ||
|
||
|
||
// Find all users that have gmail addresses and only returning their name and age fields (excluding the rest) | ||
$users = $db->query()->select('name,age')->where('email','LIKE','@gmail.com')->results(); | ||
|
||
// Instead of returning users, how about just count how many users are found. | ||
$totalUsers = $db->query()->where('email','LIKE','@gmail.com')->count(); | ||
|
||
// Delete using custom filters (this will act like a bulk delete) | ||
$db->query()->where('name','LIKE','john')->delete(function($item){ | ||
return ($item->name == 'John' && $item->email == '[email protected]'); | ||
}); | ||
|
||
``` | ||
|
||
|
@@ -403,6 +405,7 @@ To run the query use `results()` or if you only want to return the first item us | |
|`orWhere()` | `mixed` | see `where()`, this uses the logical `OR` | | ||
|`limit()` | `int` limit, `int` offset | How many documents to return, and offset | | ||
|`orderBy()` | `field` , `sort order` | Order documents by a specific field and order by `ASC` or `DESC` | | ||
|`delete()` | `Closure` | Ability to Bulk-delete all items that match | | ||
|
||
|
||
The below **methods execute the query** and return results *(do not try to use them together)* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters