Skip to content

Commit a094c93

Browse files
committedFeb 7, 2019
added update and delete to readme
1 parent f2567d5 commit a094c93

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
 

‎README.md

+39
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ It allows different syntax possibilities such as simple array/string/int values
149149
building all parameters as objects based on the [Query/...](src/Query) classes. All queries return a [QueryResult](src/Query/QueryResult.php)
150150
object, which is iterable and countable.
151151

152+
#### Select
152153
```php
153154
<?php
154155

@@ -213,6 +214,44 @@ User::query(new \Aternos\Model\Query\SelectQuery(
213214
));
214215
```
215216

217+
#### Update
218+
```php
219+
<?php
220+
221+
// update mail to "mail@example.org" where username is "username"
222+
User::query(new \Aternos\Model\Query\UpdateQuery(["email" => "mail@example.org"], ["username" => "username"]));
223+
User::query((new \Aternos\Model\Query\UpdateQuery())
224+
->fields(["email" => "mail@example.org"])
225+
->where(["username" => "username"]));
226+
User::query(new \Aternos\Model\Query\UpdateQuery(
227+
new \Aternos\Model\Query\Field("email", "mail@example.org"),
228+
new \Aternos\Model\Query\WhereCondition("username", "username")
229+
));
230+
User::query(new \Aternos\Model\Query\UpdateQuery(
231+
[new \Aternos\Model\Query\Field("email", "mail@example.org")],
232+
new \Aternos\Model\Query\WhereGroup([
233+
new \Aternos\Model\Query\WhereCondition("username", "username")
234+
])
235+
));
236+
```
237+
238+
#### Delete
239+
```php
240+
<?php
241+
242+
// delete where email is mail@example.org
243+
User::query(new \Aternos\Model\Query\DeleteQuery(["email" => "mail@example.org"]));
244+
User::query((new \Aternos\Model\Query\DeleteQuery())->where(["email" => "mail@example.org"]));
245+
User::query(new \Aternos\Model\Query\DeleteQuery(
246+
new \Aternos\Model\Query\WhereCondition("email", "mail@example.org")
247+
));
248+
User::query(new \Aternos\Model\Query\DeleteQuery(
249+
new \Aternos\Model\Query\WhereGroup([
250+
new \Aternos\Model\Query\WhereCondition("email", "mail@example.org")
251+
])
252+
));
253+
```
254+
216255
## Advanced usage
217256
*More information about more advanced usage, such as writing your own drivers, driver factory or models
218257
will be added in the future, in the meantime just take a look at the source code.*

0 commit comments

Comments
 (0)
Please sign in to comment.