title: codeiginiter: How to handel foreign key error when deleting data
body: <p>I have a problem in deleting data I wrote a function in model to delete data and it works but when foreign key constraint occur it show this error: </p>
  
  <p><a href="https://i.stack.imgur.com/DhYsv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DhYsv.png" alt="enter image description here"></a></p>
  
  <p>and I want to handle this error in the code and when this error occurs I want to show an error message: <code>You can't delete this data.</code></p>