Welcome Guest, Not a member yet? Register   Sign In
Calling model from view
#11

[eluser]gcc.programmer[/eluser]
Sitesbyjoe, I think, at least by my limited understanding, is RIGHT ON TRACK. I had mentioned using ajax to update just one section instead of refreshing the whole page with a load, but I like his idea. Hopefully this will be the ticket, instead of frantically having to re-work things.
#12

[eluser]SitesByJoe[/eluser]
A couple other things:

In your example view you have:

Code:
$this->load->model('search_process');
$found = $this->search_process->searching();
1. The loading of the model SHOULD happen in the controller.

2. You need to capitalize your model name so the line should be:
Code:
$this->load->model('Search_process');

3. The 2nd line is also wrong and should be:
Code:
$found = $this->Search_process->searching();

4. To fix all this you would put this in the controller:
Code:
$this->load->model('Search_process');
$found = $this->Search_process->searching();
$this->load->view('my_view', $found);

5. I usually have to dump all sorts of results into my views so I put things in an array that I then pass to the view like:
Code:
$data['found'] = $this->Search_process->searching();
$data['session_crap'] = $this->session->userdata('some_crap');
$this->load->view('my_view', $data);

The variable "$found" would be available in your view and you can run your loops etc the same way but the data gathering happens back in the controller where it should go.

Hopefully that helps your understand MVC a little more.
#13

[eluser]nogoodchoices[/eluser]
Thank you very much for checking out my code, you are all very generous! I will try a couple of the ideas (beginning next week as I am on vacation now) and post back for those of your who are curious.

Again, thanks everybody




Theme © iAndrew 2016 - Forum software by © MyBB