Source for file DataSource.php

Documentation is available at DataSource.php

  1. <?php
  2. /**
  3.  * Teeple2 - PHP5 Web Application Framework inspired by Seasar2
  4.  *
  5.  * PHP versions 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @package     teeple
  14.  * @author      Mitsutaka Sato <miztaka@gmail.com>
  15.  * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
  16.  */
  17.  
  18. /**
  19.  * DataSourceクラスです。
  20.  * 
  21.  * @package teeple
  22.  */
  23.     
  24.     /**
  25.      * DB接続情報を格納します。
  26.      *
  27.      * @var array 
  28.      */
  29.     private static $ds;
  30.     
  31.     /**
  32.      * コネクションを格納する配列です。
  33.      */
  34.     private $connection array();
  35.  
  36.     /**
  37.      * DB接続情報を設定します。
  38.      *
  39.      * @param array $ds DB接続情報
  40.      */
  41.     public static function setDataSource($ds{
  42.         self::$ds $ds;
  43.     }
  44.     
  45.     /**
  46.      * 指定されたDB名のConnectionを取得します。
  47.      * 
  48.      * @param dbname string DB名
  49.      * @return Object DBConnオブジェクト
  50.      */    
  51.     public function getConnection($dbname{
  52.  
  53.         $conn new Teeple_DBConn(
  54.             self::$ds[$dbname]['dsn']
  55.             self::$ds[$dbname]['user'],
  56.             self::$ds[$dbname]['pass']);
  57.         $this->connection[$conn;
  58.         return $conn;
  59.     }
  60.     
  61.     /**
  62.      * 全ての接続をクローズします。
  63.      * 
  64.      */
  65.     public function closeAll({
  66.         foreach ($this->connection as $conn{
  67.             if ($conn != NULL{
  68.                 $conn->close();
  69.             }
  70.         }
  71.     }
  72.     
  73.     /**
  74.      * DataSourceの設定を取得します。
  75.      */
  76.     public function getDataSourceConfig({
  77.         return self::$ds;
  78.     }
  79.     
  80. }
  81.  
  82. ?>

Documentation generated on Mon, 26 Apr 2010 08:59:39 +0900 by phpDocumentor 1.4.3