I\'m following an OOP mysqli course. When connecting to the database, they use the following script:
$db = new mysqli(\"host\", \"user\", \"password\", \"dat
If you need to catch exceptions on mysqli extension by use try/catch block, try this code (switch on exception mode instead of classic error reporting):
// Method 1:
$driver = new mysqli_driver();
$driver->report_mode = MYSQLI_REPORT_STRICT | MYSQLI_REPORT_ERROR;
// OR Method 2:
mysqli_report(MYSQLI_REPORT_STRICT | MYSQLI_REPORT_ALL);
try {
$db = new mysqli("host", "user", "password", "database");
} catch (mysqli_sql_exception $e) {
...
}
mysqli_sql_exception mysqli_driver