Welcome Guest, Not a member yet? Register   Sign In
Form validation: how to use is_unique(table.field1 + table.field2) ?
#1

[eluser]Genki1[/eluser]
Question:
When validating a form, can the IS_UNIQUE() rule validate that a combination of two fields is unique in the table?

Scenario:
Each user has a list of words. I want to know if the word to be inserted is unique to that user.

Table: users_words
id
word
user_id

Example:
Is the word "happy" unique to user ID #1?

Of course, I can write this simple validation routine, but it'd be nice if the functionality is already built-in.

#2

[eluser]Aken[/eluser]
Not already built in - is_unique() only checks if the string is unique to a column in a table - it doesn't narrow it down by another column at all. It's on you to add that functionality Smile
#3

[eluser]Stefan Hueg[/eluser]
[quote author="Aken" date="1335830891"]... It's on you to add that functionality Smile[/quote]

...by extending the form_validation class or writing your own callback-function Smile




Theme © iAndrew 2016 - Forum software by © MyBB