I always store database handler in $GLOBALS. I think that's the best place to save request-level-global. I wonder where other people save that kind of data.how about a static variable inside a function or a static member of a class. e.g. function getDB($args) { static $conn = array(); $key = serialize($args); if (!isset($conn[ $key ]) $conn[ $key ] = new DBConn($args); return $conn[ $key ]; }
That's surprisingly similar to how I do it. Then it's a simple matter to call getDB() (which you can do no matter what the current scope is) to get the database object.
-- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support ** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

