Welcome Guest, Not a member yet? Register   Sign In
helper problem
#1

[eluser]macron[/eluser]
I've taken over a ci project made in some old version (1.6ish) and upgraded it to 1.7.2, but I have a repeating problem on a few helpers and the usage of db.
in my controller I can do a regular $this->db->xxx. No problem. So I move this to a helper using $CI = &get;_instance(); But here I get an error on $CI->db->xxx stating db is an undefined property. Strange, I thought that &get;_instance gave a reference to the working ci object and hence one with db since I could do the db-> before a call to a function in the helper.

Any thoughts ?
#2

[eluser]WanWizard[/eluser]
I assume you mean
Code:
$CI =& get_instance();
?
#3

[eluser]macron[/eluser]
Yes. Typo. My bad. Of course $ci = & get_instance();
#4

[eluser]WanWizard[/eluser]
If you do a
Code:
$CI =& get_instance();
var_dump($CI);
What do you get?
#5

[eluser]macron[/eluser]
function get_active_languages()
{
$CI = &get;_instance();
var_dump($CI);

=>

object(user)#23 (10) {...}

Anything specific I have to look for in the Obj. Its quite large as you know?
#6

[eluser]tonanbarbarian[/eluser]
the only way that $CI->db is undefined is if the database has not been loaded, or if some processes has unset the db property.
is your database autoloaded? (i would suggest probably not)
if the helper being called in an instance in which the database has not been previously loaded?
#7

[eluser]Unknown[/eluser]
I asked so many times to so many people to give a clear answer of my question,but no one gave the right answer.Can any one give me the right answer of my question?




Theme © iAndrew 2016 - Forum software by © MyBB