Getting $mainframe class to work in objects - Joomla! Forum - community, help and support
greetings,
i have more specific question time, it'll possible answer easily!
i'm pretty new php, go gentle me... i've learned java, trying work classes. i'm using php 4.3 , joomla 1.0.11.
so: have baby component, working, in sense can test output. want include class:
include 'alluserproperties.inc'; (or require)
... fine far.
now, when try instantiate it:
fatal error: call member function on non-object in...
however: if make function rather class, fine.
i think there's problem me declaring in class constructor function:
global $mainframe;
... because when try do:
$database->setquery("select id, name, username #__users");
it doesn't seem able recognise object. if it's function, it's absolutely fine.
this php object orientation i'm not getting...?
i *could* pass in arrays need, having used database methods in main php page - that's defeating point of trying object oriented!
please poor newbie...
dan
i have more specific question time, it'll possible answer easily!
i'm pretty new php, go gentle me... i've learned java, trying work classes. i'm using php 4.3 , joomla 1.0.11.
so: have baby component, working, in sense can test output. want include class:
include 'alluserproperties.inc'; (or require)
... fine far.
now, when try instantiate it:
fatal error: call member function on non-object in...
however: if make function rather class, fine.
i think there's problem me declaring in class constructor function:
global $mainframe;
... because when try do:
$database->setquery("select id, name, username #__users");
it doesn't seem able recognise object. if it's function, it's absolutely fine.
this php object orientation i'm not getting...?
i *could* pass in arrays need, having used database methods in main php page - that's defeating point of trying object oriented!
please poor newbie...
dan
hey,
welcome joomla!
you getting error message: fatal error: call member function on non-object in... because trying invoke member function of $database not defined. assume happening in constructor?
you need do:
global $database, $mainframe;
at top of constructor. $database->setquery() work.
ian
welcome joomla!
you getting error message: fatal error: call member function on non-object in... because trying invoke member function of $database not defined. assume happening in constructor?
you need do:
global $database, $mainframe;
at top of constructor. $database->setquery() work.
ian
Comments
Post a Comment