Initialise the database connection and perform actions on the database using
a seperate class.
You can pass your functions (methods) values returned from your database
calls to manipulate.

This is commonly called a 'database abstaction layer'

Theres a good database abstraction class in this magazine by a guy called
marco talbini

Else lookup PEAR:MB or adodb library on or similar.

-----Original Message-----
From: Philip Zee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 22 January 2003 4:27 PM
Subject: [PHP-DB] Using Objects with Databases

Hello all,

I am trying to create a class, say User.  Each user has an entry in the
table called user.  Each function, including the constructor, will be
the database to do something.  Is it better to initialize the database
connection inside each function or is it better to initialize the connection
the beginning of the class?  What's the best practice on this?

Any help or example is appreciated.



PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to