I am trying form validation library of codeigniter to validate forms. I have some problem and i need help.
1.Let suppose a user fills a form to submit.
2.The validation library finds duplicates in the db table and sets error messages for the fields.
3. The form is displayed with messages.
In this method i see a draw back. Let suppose there are 5 fields in table which are set to unique. So validation will run query to find unique fields for 5 times.
The Other Method
It is to let the user insert and the db produces error. No callback_find_duplicate function here is called in form validation library. The form is populated. In this method it is difficult to find which field is duplicate so setting error message for this will be cumbersome. The worst situation is this user enters a duplicate name. Form populated, Then email then populated. Then some else and goes on.
I need to find is there a way or can we write a query which will find all duplicates for all of my fields. and set error messages for all fields with out calling callback_find_duplicate for five times. because i think calling a single query will take less execution time.
Even though form_validation is grand and all, I find myself to prefer other solutions sometimes.
Add this:
libraries/My_Form_validation.php
And then you can run it manually in your controller before
->run().Fetch the query as you may, and have an if for each case like this: