Welcome Guest, Not a member yet? Register   Sign In
Full Codeignitor Templates
#11

[eluser]crispinatari[/eluser]
yeh but each controller i've coded has its own index method in it that relates to each tables model to get all schools data (that is for one of five tables) with the same index method, i was confused as to whether having 5 index methods would clash or if instead i should create each method in only one index function.

this is my department controller for my department view and model but its not the default controller because school is:

Code:
function index()
    {
        //default method, gets data from model
        //and lists all employees using default view
        
        
      $data['title'] = "Department application";
        $data['heading'] = "Department List";
        
          /// LOADING PARTIALS //
        $data ['header']         = $this->load->view('views/header', $data, TRUE);
        $data ['menu']         = $this->load->view('views/menu', $data, TRUE);
        $data ['footer']    = $this->load->view('views/footer', $data, TRUE);  
        
        $data['res']=$this->departmentmodel->get_all_emps();
      $this->load->view('deplistview', $data);

should it be this instead

My_Controller

Code:
function index()
    {
        //default method, gets data from model
        //and lists all departments using default view
        
        
      $data['title'] = "Department application";
        $data['heading'] = "Department List";
        
          /// LOADING PARTIALS //
        $data ['header']    = $this->load->view('views/header', $data, TRUE);
        $data ['menu']      = $this->load->view('views/menu', $data, TRUE);
        $data ['footer']    = $this->load->view('views/footer', $data, TRUE);  
        
      $data['res']=$this->departmentmodel->get_all_emps();
      $this->load->view('deplistview', $data);
}
function index()
    {
        //default method, gets data from model
        //and lists all schools using default view
        
        
      $data['title'] = "School application";
      $data['heading'] = "School List";
        
          /// LOADING PARTIALS //
        $data ['header']    = $this->load->view('views/header', $data, TRUE);
        $data ['menu']      = $this->load->view('views/menu', $data, TRUE);
        $data ['footer']    = $this->load->view('views/footer', $data, TRUE);  
        
      $data['res']=$this->schoolmodel->get_all_emps();
      $this->load->view('schoollistview', $data);
#12

[eluser]jdfwarrior[/eluser]
[quote author="Dam1an" date="1244571951"][quote author="jdfwarrior" date="1244568995"]I bet I can tell you Dam1an's response Smile

Whether to do it with 5 controllers or 1 really isn't a big deal. That all comes down to preference and how you want them accessed. Typically you share a controller for data/views that are related. When it comes to the models, my stance (and I believe it was Dam1an's as well) is to make your models based on the function they perform. For instance, I have a model that handles login related functionality, a model for user related functions, etc.[/quote]

You trying to say I'm predicatble? (Or have I just answered too many similar questions?) Tongue

You where very close, but lost it on the last sentance. At least the login model is something new to me :-S Thats a library like function Tongue
[/quote]

I just remember you and I being involved in a similar discussion with someone before. And yeah, library.. brain fart. It was early, was still half asleep, I was just throwing stuff off the top of my head. I wasn't completely thinking it through (obviously). I've barely touched PHP lately, I've been trying to learn Python's Twisted framework..




Theme © iAndrew 2016 - Forum software by © MyBB