![]() |
Developing a web application, I'm using insert () to add registers to the database. I'm using the optional parameter to return a boolean value so I can check if it succeeded.
The problem is that if I try to insert a new register with a yet existing key CodeIgniter catch the exception and shows the tracing information. So I added a try..catch but it doesn't catch anything. The code I use is: PHP Code: try I've tried several exception classes (including CodeIgniter\Database\Exception\DatabaseException) but nothing works, neither debug mode nor production mode: CI overrides my code. finally does work though. Why is CI overriding my try..catch blocks and how can I prevent it? P.S: I've search both in forums and in the Internet but I've found only old threads (CI3 or CI2) or unrelated with my problem. P.S.2: If you'll say that I should check data before insert (as I've read in some old threads), I shouldn't: I want the database to check data integrity and just check if it succeeded. That's why relational databases were invented for, aren't they? |
Messages In This Thread |
Catch exeption from database insert - by Ñuño Martínez - 06-27-2024, 03:36 AM
RE: Catch exeption from database insert - by ozornick - 06-27-2024, 03:44 AM
RE: Catch exeption from database insert - by Ñuño Martínez - 06-28-2024, 01:20 AM
RE: Catch exeption from database insert - by Bosborne - 06-29-2024, 08:09 AM
RE: Catch exeption from database insert - by kenjis - 06-28-2024, 02:16 AM
RE: Catch exeption from database insert - by Ñuño Martínez - 06-28-2024, 02:21 AM
RE: Catch exeption from database insert - by kenjis - 06-29-2024, 04:27 PM
RE: Catch exeption from database insert - by Ñuño Martínez - 07-09-2024, 08:14 AM
RE: Catch exeption from database insert - by InsiteFX - 07-09-2024, 09:58 PM
RE: Catch exeption from database insert - by Ñuño Martínez - 07-15-2024, 10:34 AM
RE: Catch exeption from database insert - by sunchaser - 08-20-2024, 08:40 AM
|