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
4.[Further Examples / Stuff for Testing](#further-examples--stuff-for-testing)
21
21
5.[Contributing](#contributing)
22
22
6.[License](#license)
@@ -134,7 +134,7 @@ select(string $sql, array $where=null, int $fetch_mode=PDO::FETCH_ASSOC)
134
134
The following arguments exist:
135
135
136
136
#### SQL Query (`$sql`)
137
-
The sql to perform the query to the database. (required)
137
+
The SQL to perform the query to the database. (required)
138
138
139
139
For example:
140
140
@@ -152,7 +152,7 @@ Example:
152
152
[ 'username' => 'Jack' ]
153
153
```
154
154
155
-
Please note that you have to provide an associative array with keys that match to the placeholders in the sql query, unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
155
+
Please note that you have to provide an associative array with keys that match to the placeholders in the SQL query unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
156
156
157
157
#### PDO Fetch Mode (`$fetch_mode`)
158
158
The [pdo fetch mode](http://php.net/manual/en/pdostatement.fetch.php). Defines in which format the data is returned from the database. (optional)
The following arguments are required when calling the method:
182
182
183
183
#### SQL Query (`$sql`)
184
-
The sql query to insert the data into your database. (required)
184
+
The SQL query to insert the data into your database. (required)
185
185
186
186
For example that could be:
187
187
@@ -201,7 +201,7 @@ Example:
201
201
]
202
202
```
203
203
204
-
Please note that you have to provide an associative array with keys that match to the placeholders in the sql query, unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
204
+
Please note that you have to provide an associative array with keys that match to the placeholders in the SQL query unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
205
205
206
206
Finally, here is an example for using the `insert()` method to insert data into your database:
The sql query to delete the data from the database. (required)
230
+
The SQL query to delete the data from the database. (required)
231
231
232
232
For example:
233
233
@@ -246,7 +246,7 @@ Example:
246
246
[ 'id' => 3 ]
247
247
```
248
248
249
-
Please note that you have to provide an associative array with keys that match to the placeholders in the sql query, unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
249
+
Please note that you have to provide an associative array with keys that match to the placeholders in the SQL query unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
250
250
251
251
Simple example for deleting data with this method:
`0`:The query has been executed successfully, but no rows have been affected by it.
268
+
`0`:The query has been executed successfully, but no rows have been affected by it.
269
269
270
-
`false`:The query is completely failed.
270
+
`false`:The query is completely failed.
271
271
272
272
273
273
That leads to the following arguments:
274
274
275
275
#### SQL Query (`$sql`)
276
-
The sql query to update the data in your database. (required)
276
+
The SQL query to update the data in your database. (required)
277
277
278
278
Example:
279
279
@@ -293,7 +293,7 @@ For example that could be the following:
293
293
]
294
294
```
295
295
296
-
Please note that you have to provide an associative array with keys that match to the placeholders in the sql query, unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
296
+
Please note that you have to provide an associative array with keys that match to the placeholders in the SQL query unless you are not using the named placeholders in the query. In case you are just using the question marks as the placeholder, you can get rid of the keys.
297
297
298
298
Example for using everything this method has to offer together:
299
299
@@ -311,7 +311,7 @@ $updated = $db->update(
311
311
312
312
If you want to, you can create your own error handling setup before you instantiate the class.
313
313
314
-
Important to know is that every method returns the array `$error` on failure with some basic information about the error that is occured.
314
+
Important to know is that every method returns the array `$error` on failure with some basic information about the error that is occurred.
315
315
316
316
The following options exist:
317
317
@@ -339,7 +339,7 @@ Default:
339
339
340
340
**Attention**: Do not change the error codes/keys as long as you don't modify the class according to that! When you change the error code of an error and then just use the database class as normal, it will not work as expected!
341
341
342
-
Besides from that you can freely change the error messages to your own liking.
342
+
Besides from that, you can freely change the error messages to your own liking.
343
343
344
344
To change the config of the error handling, you must call the static method `initErrorHandler(string $env='production', array $error_types=[])`, which will basically set your specified configs, **before** you are instantiating the class.
345
345
@@ -361,7 +361,7 @@ DB::initErrorHandler(
361
361
Always make sure to pass in the whole array, e.g. not just error 2 and 5, because then only error 2 and 5 will exist.
362
362
363
363
### Check for Errors (`error()`)
364
-
In case you want to know if an error occured, you can simply call the method `error()` and it will return you `true` or `false` based on the fact whether there is an error or not.
364
+
In case you want to know if an error occurred, you can simply call the method `error()` and it will return you `true` or `false` based on the fact whether there is an error or not.
You want to see further examples for using the database class or you just want to play around with it a little bit?
395
395
396
-
- You can find a further examples in the file [`example.php`](https://github.com/jr-cologne/db-class/blob/master/example/example.php).
396
+
- You can find further examples in the file [`example.php`](https://github.com/jr-cologne/db-class/blob/master/example/example.php).
397
397
- To play around with the database class, you can use the database provided in the file [`db-class-example.sql`](https://github.com/jr-cologne/db-class/blob/master/example/db-class-example.sql). Just import that in your database client and you are ready to start!
398
398
399
399
## Contributing
400
400
Feel free to contribute to this project! It would be awesome for me if somebody contributes to it.
401
401
402
-
So don't be shy and start coding! If you want to make sure that I like your idea, you can contact me by a Issue.
402
+
So don't be shy and start coding! If you want to make sure that I like your idea, you can contact me by an Issue.
403
403
404
-
But if you decide to contribute to this project, keep in mind that finally it is my choice to merge your Pull Request or not, so also be prepared for a negative decision.
404
+
But if you decide to contribute to this project, keep in mind that finally, it is my choice to merge your Pull Request or not, so also be prepared for a negative decision.
405
405
406
406
## License
407
407
This project is licensed under the [MIT License](https://github.com/jr-cologne/db-class/blob/master/LICENSE).
0 commit comments