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

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





Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support