>> I make a database connection outside of my classes... lets call it
>> $myDBConnection. I need to use this connection in a class nested in a
>> class... Was wondering the most efficient way of doing this? I don't
>> want to create a new db connection in the class. I want to use the
>> existing one...
this is really a non-issue if you set up your classes correctly. your
base class should be the one that handles all the database interaction.
this class should have a member that stores the connection.
your extended class should be the one that is more specific to the task
at hand, i.e. managing a user.
the extended class can access all the members of the parent class the
same as if it were it's own.
<?php
class DB
{
var $connection;
function set_conn()
{
$this->connection = "hello";
}
}
class User extends DB
{
function get_connection()
{
return $this->connection;
}
}
?>
>> Any thoughts? Would it make things easyer if the base class
>> inherited all nested classes instead of nesting them?
>>
>> Any help would be appreciated.
hopefully i've sufficiently answered your question.
chris.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php