Welcome Guest, Not a member yet? Register   Sign In
Best method for sending form variables to a model ?
#2

[eluser]Rick Jolly[/eluser]
I use a variation of method #1. CI's validation can modify the $_POST array. When validating you will probably want to prep the form data. For example, I usually use "trim" to remove leading/trailing spaces. So when the validation succeeds, the $_POST array will contain the validated and prepped form data. So you could safely do this:
Code:
Controller
// if validation succeeds:
$this->model->add($_POST);

Model
$v1 = $data['var1'];
$v2 = $data['var2'];
$v3 = $data['var3'];
$this->db->query("exec spXXX '$v1','$v2','$v3'");
You could dynamically build your queries with a loop.


Messages In This Thread
Best method for sending form variables to a model ? - by El Forum - 07-22-2007, 03:44 PM
Best method for sending form variables to a model ? - by El Forum - 07-22-2007, 04:41 PM
Best method for sending form variables to a model ? - by El Forum - 07-23-2007, 11:14 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 12:42 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 02:26 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 02:38 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 02:49 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 10:35 AM
Best method for sending form variables to a model ? - by El Forum - 11-25-2008, 12:05 PM
Best method for sending form variables to a model ? - by El Forum - 11-25-2008, 12:38 PM
Best method for sending form variables to a model ? - by El Forum - 11-25-2008, 12:50 PM
Best method for sending form variables to a model ? - by El Forum - 11-26-2008, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB