|
Revision 7791, 2.1 kB
(checked in by fabien, 5 years ago)
|
updated Sean Kerr email address
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id Rev Date
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
class sfDatabaseManager |
|---|
| 24 |
{ |
|---|
| 25 |
protected |
|---|
| 26 |
$databases = array(); |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
* Retrieves the database connection associated with this sfDatabase implementation. |
|---|
| 30 |
* |
|---|
| 31 |
* @param string A database name |
|---|
| 32 |
* |
|---|
| 33 |
* @return mixed A Database instance |
|---|
| 34 |
* |
|---|
| 35 |
* @throws <b>sfDatabaseException</b> If the requested database name does not exist |
|---|
| 36 |
*/ |
|---|
| 37 |
public function getDatabase($name = 'default') |
|---|
| 38 |
{ |
|---|
| 39 |
if (isset($this->databases[$name])) |
|---|
| 40 |
{ |
|---|
| 41 |
return $this->databases[$name]; |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
$error = 'Database "%s" does not exist'; |
|---|
| 46 |
$error = sprintf($error, $name); |
|---|
| 47 |
|
|---|
| 48 |
throw new sfDatabaseException($error); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
* Initializes this sfDatabaseManager object |
|---|
| 53 |
* |
|---|
| 54 |
* @return bool true, if initialization completes successfully, otherwise false |
|---|
| 55 |
* |
|---|
| 56 |
* @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object |
|---|
| 57 |
*/ |
|---|
| 58 |
public function initialize() |
|---|
| 59 |
{ |
|---|
| 60 |
|
|---|
| 61 |
require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/databases.yml')); |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
* Executes the shutdown procedure |
|---|
| 66 |
* |
|---|
| 67 |
* @return void |
|---|
| 68 |
* |
|---|
| 69 |
* @throws <b>sfDatabaseException</b> If an error occurs while shutting down this DatabaseManager |
|---|
| 70 |
*/ |
|---|
| 71 |
public function shutdown() |
|---|
| 72 |
{ |
|---|
| 73 |
|
|---|
| 74 |
foreach ($this->databases as $database) |
|---|
| 75 |
{ |
|---|
| 76 |
$database->shutdown(); |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|