Welcome Guest, Not a member yet? Register   Sign In
codeigniter ajax database error handling
#2

(This post was last modified: 06-05-2021, 12:44 PM by includebeer.)

You need to validate your data before you try to insert in the database. This way you catch the error and display it to the user. You need to do this to prevent the database from throwing an error.

I have a tutorial on how to use the validation class: https://includebeer.com/en/blog/how-to-b...r-4-part-6

You just need to adjust what rule you need. In your case you will want the is_unique rule: http://codeigniter.com/user_guide/librar...able-rules

I just saw this was posted in the CI3 forum. There's also a validation class available in CI3, I just don't have any example on how to use it...
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply


Messages In This Thread
RE: codeigniter ajax database error handling - by includebeer - 06-05-2021, 12:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB