Welcome Guest, Not a member yet? Register   Sign In
Passing data from controller to model in an array. Please help!
#5

[eluser]Twisted1919[/eluser]
[quote author="rwestergren" date="1280011597"][quote author="Twisted1919" date="1280004657"]The $_POST is a global one, so it'll be accessible in your model as well as in your constroller, you don't need to pass it from the controller, only clean it in the model .[/quote]

In order to make a more universal model, I'd pass the array to the controller. That way you can use the model function with other data sources as well.[/quote]

True . I thought he means that the $_POST data will be used only in the model .

Anyway, one can do like
Code:
$cleaned_post = array();
foreach($_POST AS $key=>$value)
{
  $cleaned_post[$key] = $this->input->post($value,TRUE);
  $$key = $cleaned_post[$key];//so that we can use the variables as well, not only the array .
}

$this->some_model->work_with_data($cleaned_post);

$this->data['username'] = $username ;//assuming that an input field had the name username.


Messages In This Thread
Passing data from controller to model in an array. Please help! - by El Forum - 07-24-2010, 12:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB