Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel check for constraint violation

try {
  // ...

} catch (IlluminateDatabaseQueryException $e) {
    var_dump($e->errorInfo);
}

// Example output from MySQL
array (size=3)
   0 => string '23000' (length=5)
   1 => int 1452
   2 => string 'Cannot add or update a child row: a foreign key constraint fails (...)'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Laravel #check #constraint #violation
ADD COMMENT
Topic
Name
8+5 =