Hey;- >
on each controller function, am loading the SQL data, as you can see below in a code box
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Web extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->home();
}
public function home()
{
$method_name = "home";
// Model & Controller //
$this->load->model('model_get');
$data['content'] = $this->model_get->GetRecords();
$data['sub_menu'] = $this->model_get->GetChild();
$data['meta'] = $this->model_get->GetSeo($method_name);
$this->load->view('main/menu',$data);
$this->load->view('main/header');
$this->load->view('main/slider');
$this->load->view('main/features');
$this->load->view('main/calltoaction');
$this->load->view('main/pricingtable');
$this->load->view('main/statistics');
$this->load->view('main/footer');
}
public function hosting()
{
$method_name = $this->router->fetch_method();
// Model & Controller //
$this->load->model('model_get');
$data['content'] = $this->model_get->GetRecords();
$data['sub_menu'] = $this->model_get->GetChild();
$data['meta'] = $this->model_get->GetSeo($method_name);
$this->load->view('main/header');
$this->load->view('main/menu',$data);
$this->load->view('main/breadcrumbs');
$this->load->view('hosting/pricingtable');
$this->load->view('hosting/tabs');
$this->load->view('main/footer');
}
public function contact()
{
$method_name = $this->router->fetch_method();
// Model & Controller //
$this->load->model('model_get');
[b] $data['content'] = $this->model_get->GetRecords();
$data['sub_menu'] = $this->model_get->GetChild();
$data['meta'] = $this->model_get->GetSeo($method_name);[/b]
$this->load->view('main/header');
$this->load->view('main/menu',$data);
$this->load->view('main/breadcrumbs');
$this->load->view('contact/contact');
$this->load->view('main/footer');
}
public function domain()
{
$method_name = $this->router->fetch_method();
// Model & Controller //
$this->load->model('model_get');
$data['content'] = $this->model_get->GetRecords();
$data['sub_menu'] = $this->model_get->GetChild();
$data['meta'] = $this->model_get->GetSeo($method_name);
$this->load->view('main/header');
$this->load->view('main/menu',$data);
$this->load->view('main/breadcrumbs');
$this->load->view('domain/search');
$this->load->view('domain/list');
$this->load->view('main/footer');
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
Problem: Is there any way out to fetch the data in index function and shouldn't use the model and function again and again ?