I have several web projects that are all database driven. I have recently been diving 
into OOP, and rewriting a lot of procedural code in OOP. I have a design question 
about handling the MySQL connection.

I have a mysql() class which handles all my queries, automatic inserts/updates, etc. 
Just about every other class will use the mysql() class at some point.

Should I....

1) Make every class extend mysql(), so that they all have direct access to the db 
functions

2) Create a new mysql object inside of each class.

3) Only create the mysql object at the script level, and pass in the object to the 
other classes.
    I.e.:
    // Create the db object
    $mysql = new mysql();

    Now create whatever other objects I need, passing in mysql as an argument.
    $job = new job($mysql);

4) Some other idea?

Thanks for any help,

Joseph


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to