Call Model Methods inside Controllers |
[eluser]JREAM[/eluser]
If I have a Controller called "Test" like below, and I want to grab methods out of "Test_Model", how do I do this? Code: <?php Then how would you use that method? Code: $this->model->test_model->write(); I would also like to send variables to the View, and Im assuming its done with this: Code: $this->load->library('parser'); Okay, so if I have a parser like that, do I get rid of this? Code: $this->load->view('test');
[eluser]Colin Williams[/eluser]
Re-read over http://ellislab.com/codeigniter/user-gui...odels.html
[eluser]Sean Gates[/eluser]
The model can be called like: Code: $this->test_model->write(); For your next question, I don't know why are you using a parser. For BBCode, Special characters or HTML conversion? And, you should always use a view: Code: $data['item'] = 'Test Text'; -- Sean
[eluser]JREAM[/eluser]
Thanks for the fast replies. Okay I like how the model is called that way, AWESOME. I thought you used the parser if you wanted to pass variables into the View lol I also thought to use the shorthand style {$item} rather than <?php echo $item;?> you needed to use parser. Ill re-read this model area I usually skim it over to figure out what Im doing then if it's not too frustrating I keep going! |
Welcome Guest, Not a member yet? Register Sign In |