views:

19

answers:

2

Hi, I know it is not a good exepireince.But just I want to know it is possible to access a function from model or controller class from a helper file in codeignitor.

Thanks

A: 

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

Sarfraz
Thank you for your response...!!Actually I want reverse(model method from helper).I need to access a model function from helper class not wiseversa...?
Ajith
A: 

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*/
}
RobertPitt
@Robert thanks for your information
Ajith