I create a $db in my bootstrap and save a reference in Zend_Registry. I use getDefaultAdapter() whenever possible but I have some models with static methods, which by definition can't reference $this, so they pull it from the registry.
On Thu, May 15, 2008 at 11:10 AM, Kevin Hallmark <
Kevin.Hallmark@...> wrote:
I usually access the database through my table objects.
However, recently I've needed to do things directly with the database
object. I found the simplest choice was $GLOBALS['db'] = $db.
It's so rare that I directly use it, and a global lookup is pretty cheap
(right?). Anytime I need an object instantiated in my bootstrap I'll
assign it to a global. If I access it more than once in a function, I'll
either localize the variable or try and get it a more reliable way.
I didn't think about using:
Zend_Db_Table_Abstract::getDefaultAdapter();
That seems like it might be a good alternative choice.
Kevin Hallmark
PHP Developer
Bonnier Corporation
<snip/>
--
David Mintz
http://davidmintz.org/The subtle source is clear and bright
The tributary streams flow through the darkness