[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * (c) 2004-2006 Sean Kerr. 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 /** 13 * sfDatabaseManager allows you to setup your database connectivity before the 14 * request is handled. This eliminates the need for a filter to manage database 15 * connections. 16 * 17 * @package symfony 18 * @subpackage database 19 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 20 * @author Sean Kerr <skerr@mojavi.org> 21 * @version SVN: $Id: sfDatabaseManager.class.php 3210 2007-01-10 20:28:16Z fabien $ 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 // nonexistent database name 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 // load database configuration 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 // loop through databases and shutdown connections 74 foreach ($this->databases as $database) 75 { 76 $database->shutdown(); 77 } 78 } 79 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |