• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How does is_unique[...] work?

#1
PHP Code:
$this->form_validation->set_rules('username''Username'required|is_unique[users.username]'); 

Could you explain how is_unique work? What is 'users'? The controller which contains the above code named Users, so is 'users' related to the controler name? Next, what is '.username' here? How does it work?
Reply

#2
The answer to your question is in the documentation about the form_validation library:

is_unique[table.field] returns FALSE if the form element is not unique to the table and field name in the parameter. Note: This rule requires Query Builder to be enabled in order to work.

So users is the table, username is the field.

https://www.codeigniter.com/userguide3/l...dation.htm
Reply

#3
How can I check is Query Builder enabled for my project?
Reply

#4
It's enabled by default.

https://www.codeigniter.com/userguide3/d...%20enabled
Reply

#5
Wouter60, thanks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.