Как решить проблему повторения одних и тех же запросов модели для всех моих функций контроллера CodeIgniter? Для моего сайта мне нужно построить верхний и нижний колонтитул на основе почти одинаковых повторяющихся запросов к базе данных, например:
Код: Выделить всё
class Main extends CI_Controller
{
public function aboutus()
{
$this->load->model("read_db");
$commondata["title"] = "Company - ".lang("aboutus");
$commondata["mainmenu"] = $this->read_db->db_mainmenu();
$commondata["mainprodcat"] = $this->read_db->db_allprodmaincat();
$commondata["bestselling"] = $this->read_db->db_bestselling();
$commondata["brochures"] = $this->read_db->db_allbrochures();
$this->load->view("headerview", $commondata);
$contentdata["aboutus"] = $this->read_db->db_aboutus();
$this->load->view("view_aboutus", $contentdata);
$this->load->view("footerview");
}
public function contact()
{
$this->load->model("read_db");
$commondata["title"] = "Company - ".lang("contact");
$commondata["mainmenu"] = $this->read_db->db_mainmenu();
$commondata["mainprodcat"] = $this->read_db->db_allprodmaincat();
$commondata["bestselling"] = $this->read_db->db_bestselling();
$commondata["brochures"] = $this->read_db->db_allbrochures();
$this->load->view("headerview", $commondata);
$contentdata["aboutus"] = $this->read_db->db_contact();
$this->load->view("contactview", $contentdata);
$this->load->view("footerview");
}
*further functions like this*
}
Большое спасибо за любые предложения.
Подробнее здесь: https://stackoverflow.com/questions/168 ... controller
Мобильная версия