Zend_Application_Resource_Db will initialize a
Zend_Db adapter based on the options passed to it. By
default, it also sets the adapter as the default adapter for use with
Zend_Db_Table. If you want to use mutliple databases
simultaneously, you can use the Multidb Resource
Plugin.
The following configuration keys are recognized:
adapter:
Zend_Dbadapter type.params: associative array of configuration parameters to use when retrieving the adapter instance.
isDefaultTableAdapter: whether or not to establish this adapter as the default table adapter.
defaultMetadataCache: the name of the cache template or an instance of
Zend_Cache_Coreto use as metadata cache forZend_Db_Table.
Example 32. Sample DB adapter resource configuration
Below is an example INI configuration that can be used to initialize the DB resource.
[production] resources.db.adapter = "pdo_mysql" resources.db.params.host = "localhost" resources.db.params.username = "webuser" resources.db.params.password = "XXXXXXX" resources.db.params.dbname = "test" resources.db.isDefaultTableAdapter = true ; Optionally you can also the cache template to use for metadata caching: resources.db.defaultMetadataCache = "database"
Retrieving the Adapter instance
If you choose not to make the adapter instantiated with this resource the default table adapter, how do you retrieve the adapter instance?
As with any resource plugin, you can fetch the DB resource plugin from your bootstrap:
<?php
$resource = $bootstrap->getPluginResource('db');
Once you have the resource object, you can fetch the DB adapter
using the getDbAdapter() method:
<?php
$db = $resource->getDbAdapter();




