Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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(IlluminateDatabaseQueryException $ex){ 
  dd($ex->getMessage()); 
  // Note any method of class PDOException can be called on $ex.
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #catch #query #exception #laravel
ADD COMMENT
Topic
Name
1+7 =