catch db errors before returning back to controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: catch db errors before returning back to controller (/showthread.php?tid=52090) |
catch db errors before returning back to controller - El Forum - 05-29-2012 [eluser]smash120[/eluser] I have an update form which I am using to update info in my database. The account_ num is a primary key but it can be updated if user enters it wrong. I tried using Code: $this->form_validation->set_rules('acc_num','Account Number','trim|required|is_unique[patient_info.account_num]|xss_clean'); Code: Error Number: 1062 catch db errors before returning back to controller - El Forum - 05-29-2012 [eluser]sanir[/eluser] In Controller Code: $this->form_validation->set_rules('acc_num','Account Number','trim|required|is_unique[patient_info.account_num]|callback_check_duplicate|xss_clean'); catch db errors before returning back to controller - El Forum - 05-29-2012 [eluser]smash120[/eluser] @sanir I tried this but if I keep the is_unique[patient_info.account_num] part of the set_rules function it will never hit the check_duplicate function. So I removed it and know I get this error Code: A PHP Error was encountered catch db errors before returning back to controller - El Forum - 05-29-2012 [eluser]sanir[/eluser] create model with the name of duplicate_mod and create a function in that file Code: function check_unique($str) |