Jeremy Johnstone wrote:

What I would do is pass the handles to the objects in the class
constructor by reference. For example create one db object similar to
this:

class database
{
  ...
}

$db = new database();

and then pass the reference to all other classes like this:

class smarty
{
  var $db;

function smarty(&$db) {
$this->db = &$db;
}
}


This way you don't have the wasted memory of duplicate class instances.
Of course PHP5 will make this easier as it passes objects by reference
by default.

This is currently how Im doing things.
And this is what Im trying to get away from.
In addition to passing smarty the $db object by reference, Im going to be passing
the user management object to smarty by reference, which in turn has a copied reference to the $db object.
So in the end the smarty object is going to have 2 references to the $db object.
That is what I want to get away from...
$smarty <- $db (by reference)
$smarty <- $user_management (by reference) <- $db (by reference)


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



Reply via email to