Bringing DB connection into Object
Posted: Sat Mar 15, 2008 9:33 pm
Hey Everyone,
quick question... what is the best way to bring in a database connection to an object.
for instance, right now I use
global $connection;
$this->connection = $connection;
I'm trying to use PDO (the php db abstraction tool)
with it a have to use something like this:
$this->connection = DBConn::get();
but then I have to use it like this:
$this->connection->fetchAll....
which is a little tedious.
I would like to know the most elegant way of referencing a connection in objects, with PDO or without.
quick question... what is the best way to bring in a database connection to an object.
for instance, right now I use
global $connection;
$this->connection = $connection;
I'm trying to use PDO (the php db abstraction tool)
with it a have to use something like this:
$this->connection = DBConn::get();
but then I have to use it like this:
$this->connection->fetchAll....
which is a little tedious.
I would like to know the most elegant way of referencing a connection in objects, with PDO or without.