Welcome Guest, Not a member yet? Register   Sign In
Exclude insertion in the database.....($this->db->insert($table, $_POST))
#1

[eluser]kobeddon[/eluser]
when using $this->db->insert($table, $_POST); it automatically inserts all input forms in the table......my question is, is there a way to exclude an input type? lets say i have a hidden type, that i only need for my controller, and not necessarily needed in the db


....this is my first post and fairly new to CI, looking forward for the replies
#2

[eluser]PhilTem[/eluser]
Do
Code:
unset($_POST['input_key_to_unset']);
$this->db->insert($table, $_POST);


which is the easiest way. Of course you can have an array representing all fields of your table and then clean the $_POST with

Code:
$cleaned_post = array_intersect($table_fields, $_POST);

assuming you have same names for both the table-fields as well as the input-fields.
Refer to http://php.net/manual/en/function.array-...ct-key.php for more info.
#3

[eluser]kobeddon[/eluser]
thanks for the reply... i think ill try that unset method creating the array would take too long as the table is pretty big




Theme © iAndrew 2016 - Forum software by © MyBB