Welcome Guest, Not a member yet? Register   Sign In
check if a value already exists in database
#3

There is also a built-in validation rule for that: is_unique.
https://www.codeigniter.com/user_guide/l...-reference

Note that under CI version 2, if you chained validation rules, you could not put spaces between them.
PHP Code:
// works
$this->form_validation->set_rules('email''Email''required|is_unique[users.email]');
// doesn't work
$this->form_validation->set_rules('email''Email''required | is_unique[users.email]'); 
Usually, white space doesn't matter in code, but in this case, it does. I don't know if that's still the case in version 3, but just so you know...
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply


Messages In This Thread
RE: check if a value already exists in database - by RobertSF - 01-02-2016, 01:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB