Skip to content

Commit 0e3985b

Browse files
committed
update README
1 parent 0f8abc9 commit 0e3985b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ to the `require section` of your `composer.json` file.
4545
- `reset()` resets state to default values (except PDO property)
4646
- `all()` executes SQL query and return all rows of result (`fetchAll()`)
4747
- `one()` executes SQL query and return the first row of result (`fetch()`)
48-
- `column()` executes SQL query and return the first column of result (`fetchColumn()`)
49-
- `pluck($key_index, $col_index)` executes SQL query and returns an array (the key (usually ID) and the needed column of result), `key_index` is `0` and `col_index` is `1` by default
48+
- `column($col)` executes SQL query and returns the needed column of result by its name, `col` is `'id'` by default
49+
- `pluck($key, $col)` executes SQL query and returns an array (the key (usually ID) and the needed column of result) by their names, `key` is `id` and `col` is `''` by default
5050
- `go()` this method is for non `SELECT` queries. it executes SQL query and return nothing (but returns the last inserted row ID for `INSERT` method)
5151
- `count()` prepares a query with SQL `COUNT(*)` function and executes it
52-
- `exists()` returns `true` if SQL query result has a row
52+
- `exists()` returns `true` if SQL query result has a row and `false` if it hasn't
5353
- `query($sql, $params[], $fetch_type)` executes prepared `$sql` with `$params`. it can be used for custom queries
5454
- 'SQL' methods are presented in [Usage section](#usage-examples)
5555

@@ -66,7 +66,10 @@ use co0lc0der\QueryBuilder\QueryBuilder;
6666
```
6767
### Init `QueryBuilder` with `Connection::make()`
6868
```php
69-
$query = new QueryBuilder(Connection::make($config['database']));
69+
$query = new QueryBuilder(Connection::make($config['database'])); // $printErrors = false
70+
71+
// for printing errors (since 0.3.6)
72+
$query = new QueryBuilder(Connection::make($config['database']), true)
7073
```
7174
### Usage examples
7275
- Select all rows from a table
@@ -107,6 +110,8 @@ SELECT * FROM `users` WHERE (`id` > 1) AND (`group_id` = 2);
107110
$results = $query->select('users')->like(['name', '%John%'])->all();
108111
// or
109112
$results = $query->select('users')->where([['name', 'LIKE', '%John%']])->all();
113+
// or since 0.3.6
114+
$results = $query->select('users')->like('name', '%John%')->all();
110115
```
111116
```sql
112117
SELECT * FROM `users` WHERE (`name` LIKE '%John%');
@@ -115,6 +120,8 @@ SELECT * FROM `users` WHERE (`name` LIKE '%John%');
115120
$results = $query->select('users')->notLike(['name', '%John%'])->all();
116121
// or
117122
$results = $query->select('users')->where([['name', 'NOT LIKE', '%John%']])->all();
123+
// or since 0.3.6
124+
$results = $query->select('users')->notLike('name', '%John%')->all();
118125
```
119126
```sql
120127
SELECT * FROM `users` WHERE (`name` NOT LIKE '%John%');

0 commit comments

Comments
 (0)