Hi I've been stressing over a problem I am having whilst trying to get to grips with the whole OOP concept in PHP 5. If I explain the situation hopefully someone may be able to help.
I have a database class that has methods that basically execute mysqli functions to 'open a connection', 'create a recordset' etc...
I have a sysConfig class that gives access to configuration information. This information is just a list of fields read from the database table.
Now when the sysConfig class is constructed it needs a connection to the database to read in the config record, so it needs to access the database class, as I understand creating an object within another object is a bad idea.
Whats the best way or doing this? Should the main code first create the database object, thus creating the connection and then passing that to each method in the sysConfig class? Or can the database object reference be stored in the sysConfig class somewhere (ie. $objSysConf->setConnection( $objDB ) )?
Any advice/pointers on this newb question would be appreciated. I've trawled through loads of articles regarding OOP and some are beyond me whilst others don't seem to fit the problem.
Thanks in advance.