Link to home
Start Free TrialLog in
Avatar of Hube02
Hube02Flag for United States of America

asked on

php nested classes

I have a class that I use for all of my MySQL functions. Connecting to the database, getting records writing records, etc...

I'm now developing a catalog for a client and I wish to use a class here as well. If I create a MySQL object inside of the new Catalog class, how do I refer to the properties of the MySQL object.

Here is an example of some of my code, not exact, but you should get the idea.

class Catalog {
  var ...............
    .............. more property definitions

  var $db_connection;

  function Catalog() {
    if ($this->db_connection = new MySQL(DB_HOST, DB_USER, DB_PASSWORD, DB_DB)) {
       
    }

---------------------------------

now, one of the properties of the MySQL object is $return_array. I would usually refer to this property as:
 $db_connection->return_array
 
within the Catalog Class would I refer to this property as $this->db_connection->return_array ?

is this correct?

somehow that does not look right to me. Can someone tell me how to refer to that property? Am I going about this the wrong way? Is there a better way to accomplish what I am after?
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hube02

ASKER

Thanks, I needed to be sure. Trying very hard to move completely away from procedural programming techniques.