开发者

Access function from model class or controller class from helper file with Codeigniter

I know it is not a good experience. But just I want to know it is possible to access a function from model or controller class from a helper file 开发者_如何学Goin codeigniter.


cant you use something like this i believe.

$Helper =& load_class('Helper'); //Load the (Helper Loader) $this->load->helper becomes $helper
$Class = $Helper('Name of class');

But i do not see why you should do this

Can't you just create an extra model class like

class DBFile
{
   ...
}

then create your Model

class Model_SomeName extends DBFile
{
  /*So no this uses DBFile instead of CI_Database or w.e it is*/
}


Yes, that is possible, you will have to load the helper class first like this:

$this->load->helper('name of helper class');

More Info:

http://codeigniter.com/user_guide/helpers/array_helper.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜