laravel handle queryexception
try {
$this->model->create($data);
} catch (Illuminate\Database\QueryException $e) {
dd($e);
} catch (PDOException $e) {
dd($e);
}
laravel handle queryexception
try {
$this->model->create($data);
} catch (Illuminate\Database\QueryException $e) {
dd($e);
} catch (PDOException $e) {
dd($e);
}
how to catch query exception in laravel 8
try {
$results = \DB::connection("example")
->select(\DB::raw("SELECT * FROM unknown_table"))
->first();
// Closures include ->first(), ->get(), ->pluck(), etc.
} catch(\Illuminate\Database\QueryException $ex){
dd($ex->getMessage());
// Note any method of class PDOException can be called on $ex.
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us