Hi all:-still learning OOP.
I am writing a class that deals with a personal ad and has methods to insert/create, update, delete, approve, etc. All methods will require a DB connection.
I am using PEAR DB. I create the DB connection with:
require_once 'DB.php';
$dblogin= 'mysql://usr: pwd@localhost/DB';
$ntgdb = DB::connect($dblogin);
Should I:
a. create the DB connection once at the top of the page that defines the class (but outside the class construct)
b. create the db connection upon object instantiation
c. create a db connection inside each method.
I know it is a rudimentary question but I wasn't sure...