Welcome Guest, Not a member yet? Register   Sign In
Cannot pass variables from Controller to Model
#3

Whether this works or not, this is just a bad coding habit. Without comments, there's no way to show where the variable was set (in your model), or what you're doing with it (in your controller).

In your controller, you should do this instead:

Code:
$this->news_model->test_message = 'this is a test';

Even better would be to pass the message from the controller to the model in a method call:

Code:
// Controller
$message = 'this is a test';
$this->news_model->set_message( $message );
Code:
// Model
public function set_message( $message )
{
  $this->test_message = $message;
}
Reply


Messages In This Thread
RE: Cannot pass variables from Controller to Model - by skunkbad - 05-29-2016, 08:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB