Skip to content

Commit a4ebb98

Browse files
author
Ettemlevest
committed
Adding error helper functions
1 parent 631decd commit a4ebb98

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ MysqliDb -- Simple MySQLi wrapper and object mapper with prepared statements
1919
**[Has method](#has-method)**
2020
**[Helper Methods](#helper-methods)**
2121
**[Transaction Helpers](#transaction-helpers)**
22+
**[Error Helpers](#error-helpers)**
2223

2324
### Installation
2425
To utilize this class, first import MysqliDb.php into your project, and require it.
@@ -621,6 +622,17 @@ if (!$db->insert ('myTable', $insertData)) {
621622
}
622623
```
623624

625+
### Error helpers
626+
After you executed a query you have options to check if there was an error. You can get the MySQL error string or the error code for the last executed query.
627+
```php
628+
$db->where('login', 'admin')->update('users', ['firstName' => 'Jack']);
629+
630+
if ($db->getLastErrno() === 0)
631+
echo 'Update succesfull';
632+
else
633+
echo 'Update failed. Error: '. $db->getLastError();
634+
```
635+
624636
### Query exectution time benchmarking
625637
To track query execution time setTrace() function should be called.
626638
```php

0 commit comments

Comments
 (0)