Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
midorikocak committed Feb 4, 2020
1 parent 5c73535 commit 04d014b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ There are starter methods to create a query, such as `SELECT` and `UPDATE`.

### Select

``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users');
echo $queryMaker->getQuery();
Expand All @@ -47,7 +47,7 @@ SELECT * FROM users
### Select with fields
Fields to select can be specified as well:

``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users', ['id', 'email']);
echo $queryMaker->getQuery();
Expand All @@ -63,7 +63,7 @@ SELECT id, email FROM users

Field values can include operators, such as: `=`,`>`, `<`,`<=`,`>=`

``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users', ['id', 'email'])->where('id', '3', '>=');
echo $queryMaker->getQuery();
Expand All @@ -79,7 +79,7 @@ SELECT id, email FROM users WHERE id>=:id'
### Delete
``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->delete('users');
echo $queryMaker->getQuery();
Expand All @@ -95,7 +95,7 @@ DELETE FROM users
To specify `WHERE` clauase use `where($key, $value)` method.
``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users', ['id', 'email'])->where('id', 3);
echo $queryMaker->getQuery();
Expand All @@ -113,7 +113,7 @@ SELECT id, email FROM users WHERE id=:id
Contraints such as `AND` and `OR`, are methods as well. `and($key, $value)` and `or($key, $value)`
``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users', ['id', 'email'])->where('id', 3)->and('email', 'mtkocak@gmail.com')->or('username', 'midori');
echo $queryMaker->getQuery();
Expand All @@ -129,7 +129,7 @@ SELECT id, email FROM users WHERE id=:id OR username=:username
Multiple AND and OR clauses can have same field conditions.
``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users', ['id', 'email'])->where('email', 'mtkocak@gmail.com')->and('id', '>3')->and('id', '<5');
```
Expand All @@ -138,7 +138,7 @@ $queryMaker->select('users', ['id', 'email'])->where('email', '[email protected]
To specify `ORDER BY` clauase use `order($key, $order)` method.
``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users')->orderBy('id');
echo $queryMaker->getQuery();
Expand All @@ -155,7 +155,7 @@ SELECT * FROM users ORDER BY id ASC
To specify `OFFSET` and `LIMIT` clauase use `offset($offset)` and `limit($offset)` methods.
``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->select('users')->orderBy('id')->limit(3)->offset(2);
echo $queryMaker->getQuery();
Expand All @@ -171,7 +171,7 @@ SELECT * FROM users ORDER BY id ASC LIMIT 3 OFFSET 2
It's also possible to get values as key value pair to easily execute.

``` php
```php
$db = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$queryMaker = new QueryMaker();
Expand All @@ -187,7 +187,7 @@ $statement->execute($query->getParams());

To specify `INSERT` operation, `insert()` method, expects a key value array.

``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->insert('users', ['email' => '[email protected]', 'username' => 'midorikocak']);
Expand All @@ -207,7 +207,7 @@ INSERT INTO users (email, username) VALUES (:email, :username)

To specify `UPDATE` operation, handy `update()` method, expects a key value array. All statement params are generated thoroughly.

``` php
```php
$queryMaker = new QueryMaker();
$queryMaker->update('users', ['email' => '[email protected]', 'username' => 'midorikocak'])->where('id', 3);
echo $queryMaker->getQuery();
Expand Down

0 comments on commit 04d014b

Please sign in to comment.