Welcome Guest, Not a member yet? Register   Sign In
posted data + field not in table
#1

[eluser]allibubba[/eluser]
ok, so a quick layout of what i'm doing.

my form:
-name
-email
-emailConfirm
-password
-passwordConfirm

and my table is of course the same:
-id
-name
-email
-emailConfirm
-password
-passwordConfirm

and when validation is passed i update like so:
Code:
$this->db->insert('users', $_POST);

this works fine, but what i would like to do is not have emailConfirm and passwordConfirm in my table (need them in my form for validation though), it makes editing and updating accounts a pain.
i would like my table to just be this:
-id
-name
-email
-password

but i get an error:
Unknown column 'emailConfirm' in 'field list'

i know i could do something like this:
Code:
$this->db->set('name', $name);
$this->db->set('email', $email);
$this->db->set('password', $password);
$this->db->insert('mytable');

but that seems like an inefficient way of doing things, especially since my form and table are actually a lot larger, i gather addresses for billing and shipping and a bunch of other stuff. so i guess i'm wondering how i can filter out formfields from my post data? i know i could set up an ajax call to handle this, but for now i would like to keep all my functionality in CI (still learning the framework)
#2

[eluser]kidego32[/eluser]
Hi,

check out this link:

Model Helpers

The function compares the table POST data against the table fields, and removes (unsets) the ones that aren't in the table.

Hope it helps.
#3

[eluser]allibubba[/eluser]
nice, i'll take a closer look at this later, but it looks like exactly what i was thinking




Theme © iAndrew 2016 - Forum software by © MyBB