Welcome Guest, Not a member yet? Register   Sign In
Is_Unique validation with custom db table
#1

[eluser]wehappyfew[/eluser]
Hello to all,

i am trying to create a custom table for every user that is creating an account in my site.
For example:

Code:
function add_client($form_inputs)
{
  //create the table name
  $username = $this->session->userdata('username');
  $table_name = $username . "_clients";
  //
  $this->db->insert($table_name,$form_inputs);
}
The above works fine.
BUT...i would like something more.
I would like a form validation to check for unique values in the custom table.

for example:

Code:
$field_rules =array
               (
                     'field'   => 'client_name',
                     'label'   => '-Client\'s name-',
                     'rules'   =>
required|
max_length[30]|
----------------> is_unique[{$username}_clients.client_name]|
alpha_dash|trim'
               )
The thing is that i dont know how to "integrate" the username variable into the validation.
Thank you in advance!


Oh..i though of something else that may be a solution.
It would be the same if i could create a table from the DBFORGE class ( create_table() ) where i could set the colunm index as UNIQUE.
But it seems that is not possible to set the column index anyway.


Messages In This Thread
Is_Unique validation with custom db table - by El Forum - 04-04-2012, 07:03 AM
Is_Unique validation with custom db table - by El Forum - 04-04-2012, 11:51 AM
Is_Unique validation with custom db table - by El Forum - 04-04-2012, 01:06 PM
Is_Unique validation with custom db table - by El Forum - 04-04-2012, 01:38 PM
Is_Unique validation with custom db table - by El Forum - 04-06-2012, 06:07 AM
Is_Unique validation with custom db table - by El Forum - 04-06-2012, 07:30 AM
Is_Unique validation with custom db table - by El Forum - 04-06-2012, 09:19 AM
Is_Unique validation with custom db table - by El Forum - 04-06-2012, 09:23 AM
Is_Unique validation with custom db table - by El Forum - 04-07-2012, 05:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB