Phundament-Packages
[ class tree: Phundament-Packages ] [ index: Phundament-Packages ] [ all elements ]

Source for file LDatabase.php

Documentation is available at LDatabase.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * LDatabase class file.
  6.  *
  7.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9.  * @author $Author: schmunk $
  10.  * @version $Revision: 601 $  $Date: 2007-02-24 23:49:30 +0100 (Sa, 24 Feb 2007) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LDatabase
  13.  */
  14.  
  15. /**
  16.  * Provides database intialization and access.
  17.  *
  18.  * @package System.Data
  19.  * @subpackage Modules
  20.  */
  21. Prado :: using("Library.propel.*");
  22.  
  23. Prado :: using("Library.propel.runtime.classes.propel.util.*");
  24. Prado :: using("Library.propel.runtime.classes.propel.adapter.*");
  25. Prado :: using("Library.propel.runtime.classes.propel.map.*");
  26. Prado :: using("Library.propel.runtime.classes.propel.om.*");
  27. Prado :: using("Library.propel.runtime.classes.propel.*");
  28. Prado :: using("Library.propel.runtime.classes.*");
  29.  
  30. Prado :: using("Library.creole.classes.creole.common.*");
  31. Prado :: using("Library.creole.classes.creole.drivers.sqlite.*");
  32. Prado :: using("Library.creole.classes.creole.drivers.mysql.*");
  33. Prado :: using("Library.creole.classes.creole.*");
  34. Prado :: using("Library.creole.classes.*");
  35.  
  36. Prado :: using("Library.log.*");
  37. Prado :: using("Library.log.Log.*");
  38.  
  39. class LDatabase extends TModule
  40. {
  41.     /**
  42.      * Location of master config file
  43.      */
  44.     private $_masterConfigFile;
  45.  
  46.     /**
  47.      * Config handler
  48.      */
  49.     public $DatabaseConfig;
  50.  
  51.     /**
  52.      * Returns location of config file (within package dir)
  53.      */
  54.     public function getMasterConfigFile()
  55.     {
  56.         return $this->_masterConfigFile;
  57.     }
  58.  
  59.     /**
  60.      * Sets location of config file (within package dir)
  61.      */
  62.     public function setMasterConfigFile($value)
  63.     {
  64.         $this->_masterConfigFile$value;
  65.     }
  66.  
  67.     /**
  68.      * Inits database configutation
  69.      */
  70.     public function init($config)
  71.     {
  72.         $this->DatabaseConfignew LDatabaseConfiguration();
  73.         $this->DatabaseConfig->init($config);
  74.         Prado :: trace("LDatabase initialized "'Lithron.LDatabase');
  75.         parent :: init($config);
  76.     }
  77.  
  78.     /**
  79.      * Returns a propel or creole (which is faster) connection
  80.      */
  81.     public function getConnection($name$layer"propel")
  82.     {
  83.         static $connections;
  84.         if (isset ($connections[$layer ":" $name]))
  85.         {
  86.             Prado :: trace("Returning pooled connection ($namewith $layer ... "'Lithron.LDatabase');
  87.             return $connections[$layer ":" $name];
  88.         }
  89.  
  90.         if (!is_array($this->DatabaseConfig->_config['propel']['datasources'][$name]))
  91.             $this->DatabaseConfig->_config['propel']['datasources'][$name]$this->DatabaseConfig->_config['propel']['datasources']["development"]// TODO
  92.  
  93.         switch ($layer)
  94.         {
  95.             case 'propel' :
  96.                 $connLPropel :: getConnection($name);
  97.                 break;
  98.             default :
  99.                 $dsn$this->DatabaseConfig->getDsn($name)// not implem. TODO
  100.                 $connLCreole :: getConnection($dsnCreole :: PERSISTENT);
  101.                 break;
  102.         }
  103.         Prado :: trace("Returning connection ($namewith $layer ... "'Lithron.LDatabase');
  104.         $connections[$layer ":" $name]$conn;
  105.         return $conn;
  106.  
  107.     }
  108. }
  109. ?>

Documentation generated on Sun, 25 Feb 2007 16:10:17 +0100 by phpDocumentor 1.3.1