Welcome Guest, Not a member yet? Register   Sign In
Autoload config and models trick
#1

1: If config exists, load it!
2: If table exists, load model!
Code:
if(is_file($file = APPPATH.'config/'.$this->router->class.'.php') !== false)
{
$this->config->load($this->router->class);
}
if($this->db->table_exists($this->router->class))
{
$this->load->models(array($this->router->class.'_model' => $this->router->class));
}
If you're adding fwrite a model in MY_Model if class exists as table, you've dynamic models loaded for each table!
Reply


Messages In This Thread
Autoload config and models trick - by Everterstraat - 03-27-2015, 06:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB