[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 941
  • Last Modified:

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?
0
Hube02
Asked:
Hube02
1 Solution
 
hernst42Commented:
> within the Catalog Class would I refer to this property as $this->db_connection->return_array ?
yes that a correct
0
 
Hube02Author Commented:
Thanks, I needed to be sure. Trying very hard to move completely away from procedural programming techniques.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now