📜  Laravel 检查约束违规 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:45.737000             🧑  作者: Mango

代码示例1
try {
  // ...

} catch (\Illuminate\Database\QueryException $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 (...)'