Why not do this:

public function _initDbCache()
{
    // bootstrap DB
    $this->bootstrap('db');
    $dbAdapter = $this->getResource('db');

    // bootstrap cache
    $this->bootstrap('cache');
    $cache = $this->getResource('cache');

    // set db metadata cache
    Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);

}

Konr

On Thu, Jan 28, 2010 at 10:19 PM, Hector Virgen <[email protected]> wrote:

> I initially was going to create a new _init method in my bootstrap to tie
> the two together, but it seemed awkward to have two different pieces of code
> that "bootstrapped" the database. My current solution is to extend the Db
> resource to provide this functionality, but it seems like something I'd use
> in most (if not all) of my ZF applications.
>
> I'll create the enhancement request for this and work on the patch / unit
> tests now.
>
> --
> Hector
>
>
>
> On Thu, Jan 28, 2010 at 8:12 PM, Konr Ness <[email protected]> wrote:
>
>> That's a good idea.
>>
>> I think the only option is to set the default metadata cache in your
>> Bootstrap.
>>
>> Konr
>>
>>
>> On Thu, Jan 28, 2010 at 2:24 PM, Hector Virgen <[email protected]>wrote:
>>
>>> Hello,
>>>
>>> I'm really enjoying the improvements made in version 1.10.0. Now that we
>>> have a cache manager resource (which is really nice, btw!), is there a
>>> standardized way of setting the default metadata cache for Zend_Db_Table?
>>>
>>> I was looking through the source for the built-in "Db" resource plugin,
>>> and from what I can tell the answer is "no". The only thing I could find
>>> that had anything to do with Zend_Db_Table was the setting of the default
>>> adapter. It would be nice if we could also specify a cache manager key to
>>> use for setting the default metadata cache, something like this:
>>>
>>> ; Cache Manager
>>> resources.cachemanager.database.frontend.name = "Core"
>>> resources.cachemanager.database.frontend.options.lifetime = 7200
>>> resources.cachemanager.database.frontend.options.automatic_serialization
>>> = true
>>> resources.cachemanager.database.backend.name = "Sqlite"
>>>  resources.cachemanager.database.backend.options.cache_db_complete_path
>>> = APPLICATION_PATH "/../data/cache/database.sqlite"
>>>
>>> ; Database
>>> resources.db.adapter = "pdo_mysql"
>>> resources.db.params.host = "localhost"
>>> resources.db.params.username = "my_username"
>>> resources.db.params.password = "my_password"
>>> resources.db.params.dbname = "my_db"
>>> resources.db.isDefaultTableAdapter = true
>>> *resources.db.defaultMetadataCache = "database"*
>>>
>>> That last line is what would tell the db resource plugin which cache to
>>> use and it would pull it from the cache manager.
>>>
>>> I've extended the Db resource plugin to support this, but I think others
>>> may find it useful too. If there's a better way of handling this, let me
>>> know, otherwise I'll open an "improvement" bug and upload a patch.
>>>
>>> --
>>> Hector
>>>
>>
>>
>

Reply via email to