Application/Resource/Multidb.php
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Application
- Subpackage
- Resource
- Version
- $Id: Multidb.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Application_Resource_Multidb
Example configuration:
resources.multidb.defaultMetadataCache = "database" resources.multidb.db1.adapter = "pdo_mysql" resources.multidb.db1.host = "localhost" resources.multidb.db1.username = "webuser" resources.multidb.db1.password = "XXXX" resources.multidb.db1.dbname = "db1" resources.multidb.db1.default = true resources.multidb.db2.adapter = "pdo_pgsql" resources.multidb.db2.host = "example.com" resources.multidb.db2.username = "dba" resources.multidb.db2.password = "notthatpublic" resources.multidb.db2.dbname = "db2"
- Parent(s)
- \Zend_Application_Resource_ResourceAbstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties

array $_dbs = array()array()Details- Type
- array

null|\Zend_Db_Adapter_Abstract $_defaultDb- Type
- null | \Zend_Db_Adapter_Abstract

array $_options = array()array()Details- Type
- array
- Inherited_from
- \Zend_Application_Resource_ResourceAbstract::$$_options

array $_skipOptions = array('options', 'config')array('options', 'config')Details- Type
- array
- Inherited_from
- \Zend_Application_Resource_ResourceAbstract::$$_skipOptions
Methods

__construct(mixed $options = null) : voidCreate a instance with options
Inherited from: \Zend_Application_Resource_ResourceAbstract::__construct()Must take an optional single argument, $options.
| Name | Type | Description |
|---|---|---|
| $options | mixed |

_setDefault( $adapter) : voidSet the default db adapter
| Name | Type | Description |
|---|---|---|
| $adapter |
- \Zend_Db_Adapter_Abstract
Adapter to set as default

_setDefaultMetadataCache(string | \Zend_Cache_Core $cache) : \Zend_Application_Resource_MultidbSet the default metadata cache
| Name | Type | Description |
|---|---|---|
| $cache | string | \Zend_Cache_Core |
| Type | Description |
|---|---|
| \Zend_Application_Resource_Multidb |

getBootstrap() : null | \Zend_Application_Bootstrap_BootstrapperRetrieve the bootstrap to which the resource is attached
Inherited from: \Zend_Application_Resource_ResourceAbstract::getBootstrap()| Type | Description |
|---|---|
| null | \Zend_Application_Bootstrap_Bootstrapper |

getDb(null | string | \Zend_Db_Adapter_Abstract $db = null) : \Zend_Db_Adapter_AbstractRetrieve the specified database connection
| Name | Type | Description |
|---|---|---|
| $db | null | string | \Zend_Db_Adapter_Abstract | The adapter to retrieve. Null to retrieve the default connection |
| Type | Description |
|---|---|
| \Zend_Db_Adapter_Abstract |
| Exception | Description |
|---|---|
| \Zend_Application_Resource_Exception | if the given parameter could not be found |

getDefaultDb(boolean $justPickOne = true) : null | \Zend_Db_Adapter_AbstractGet the default db connection
| Name | Type | Description |
|---|---|---|
| $justPickOne | boolean | If true, a random (the first one in the stack) connection is returned if no default was set. If false, null is returned if no default was set. |
| Type | Description |
|---|---|
| null | \Zend_Db_Adapter_Abstract |

getOptions() : arrayRetrieve resource options
Inherited from: \Zend_Application_Resource_ResourceAbstract::getOptions()| Type | Description |
|---|---|
| array |

init() : \Zend_Application_Resource_MultidbInitialize the Database Connections (instances of Zend_Db_Table_Abstract)
| Type | Description |
|---|---|
| \Zend_Application_Resource_Multidb |

isDefault(string | \Zend_Db_Adapter_Abstract $db) : booleanDetermine if the given db(identifier) is the default db.
| Name | Type | Description |
|---|---|---|
| $db | string | \Zend_Db_Adapter_Abstract | The db to determine whether it's set as default |
| Type | Description |
|---|---|
| boolean | True if the given parameter is configured as default. False otherwise |

mergeOptions(array $array1, mixed $array2 = null) : arrayMerge options recursively
Inherited from: \Zend_Application_Resource_ResourceAbstract::mergeOptions()| Name | Type | Description |
|---|---|---|
| $array1 | array | |
| $array2 | mixed |
| Type | Description |
|---|---|
| array |

setBootstrap(\Zend_Application_Bootstrap_Bootstrapper $bootstrap) : \Zend_Application_Resource_ResourceSet the bootstrap to which the resource is attached
Inherited from: \Zend_Application_Resource_ResourceAbstract::setBootstrap()| Name | Type | Description |
|---|---|---|
| $bootstrap | \Zend_Application_Bootstrap_Bootstrapper |
| Type | Description |
|---|---|
| \Zend_Application_Resource_Resource |

setOptions(array $options) : \Zend_Application_Resource_ResourceAbstractSet options from array
Inherited from: \Zend_Application_Resource_ResourceAbstract::setOptions()| Name | Type | Description |
|---|---|---|
| $options | array | Configuration for resource |
| Type | Description |
|---|---|
| \Zend_Application_Resource_ResourceAbstract |