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
+85-4Lines changed: 85 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,14 @@ This is a small easy-to-use PHP component for working with a database by PDO. It
10
10
11
11
**PAY ATTENTION! v0.2 and v0.3+ are incompatible.**
12
12
13
+
## Contributing
14
+
15
+
Bug reports and/or pull requests are welcome
16
+
17
+
## License
18
+
19
+
The package is available as open source under the terms of the [MIT license](https://github.com/co0lc0der/simple-query-builder-php/blob/main/LICENSE.md)
20
+
13
21
## Installation
14
22
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
15
23
@@ -21,15 +29,15 @@ or add
21
29
```json
22
30
"co0lc0der/simple-query-builder": "*"
23
31
```
24
-
to the require section of your `composer.json` file.
32
+
to the `require section` of your `composer.json` file.
25
33
26
34
## How to use
27
35
### Main public methods
28
36
-`getSql()` returns SQL query string which will be executed
29
37
-`getParams()` returns an array of parameters for a query
30
38
-`getResult()` returns query's results
31
39
-`getCount()` returns results' rows count
32
-
-`getError()` returns `true` if an error is had
40
+
-`hasError()` returns `true` if an error is had
33
41
-`getErrorMessage()` returns an error message if an error is had
34
42
-`setError($message)` sets `$error` to `true` and `$errorMessage`
35
43
-`getFirst()` returns the first item of results
@@ -38,8 +46,10 @@ to the require section of your `composer.json` file.
38
46
-`all()` executes SQL query and return all rows of result (`fetchAll()`)
39
47
-`one()` executes SQL query and return the first row of result (`fetch()`)
40
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
41
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)
42
51
-`count()` prepares a query with SQL `COUNT()` function
52
+
-`exists()` returns `true` if SQL query result has a row
43
53
-`query($sql, $params[], $fetch_type)` executes prepared `$sql` with `$params`. it can be used for custom queries
44
54
- 'SQL' methods are presented in [Usage section](#usage-examples)
0 commit comments