You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,11 +45,11 @@ to the `require section` of your `composer.json` file.
45
45
-`reset()` resets state to default values (except PDO property)
46
46
-`all()` executes SQL query and return all rows of result (`fetchAll()`)
47
47
-`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
50
50
-`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)
51
51
-`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
53
53
-`query($sql, $params[], $fetch_type)` executes prepared `$sql` with `$params`. it can be used for custom queries
54
54
- 'SQL' methods are presented in [Usage section](#usage-examples)
55
55
@@ -66,7 +66,10 @@ use co0lc0der\QueryBuilder\QueryBuilder;
66
66
```
67
67
### Init `QueryBuilder` with `Connection::make()`
68
68
```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)
70
73
```
71
74
### Usage examples
72
75
- Select all rows from a table
@@ -107,6 +110,8 @@ SELECT * FROM `users` WHERE (`id` > 1) AND (`group_id` = 2);
0 commit comments