コード例 #1
0
ファイル: Db.php プロジェクト: EtienneBruines/redaxscript
 /**
  * init the class
  *
  * @since 2.2.0
  *
  * @param Config $config instance of the config class
  */
 public static function init(Config $config)
 {
     self::$_config = $config;
     $dbType = $config->get('dbType');
     $dbHost = $config->get('dbHost');
     $dbName = $config->get('dbName');
     $dbUser = $config->get('dbUser');
     $dbPassword = $config->get('dbPassword');
     /* mysql and pgsql */
     if ($dbType === 'mysql' || $dbType === 'pgsql') {
         if ($dbType === 'mysql') {
             self::configure('connection_string', 'mysql:host=' . $dbHost . ';dbname=' . $dbName . ';charset=utf8');
         } else {
             self::configure('connection_string', 'pgsql:host=' . $dbHost . ';dbname=' . $dbName . ';options=--client_encoding=utf8');
         }
         /* username and password */
         self::configure(array('username' => $dbUser, 'password' => $dbPassword));
     }
     /* sqlite */
     if ($dbType === 'sqlite') {
         self::configure('sqlite:' . $dbHost);
     }
     /* general */
     self::configure(array('caching' => true, 'caching_auto_clear' => true, 'return_result_sets' => true));
 }
コード例 #2
0
ファイル: Db.php プロジェクト: redaxmedia/redaxscript
 /**
  * constructor of the class
  *
  * @since 2.6.0
  *
  * @param Config $config instance of the config class
  */
 public static function construct(Config $config)
 {
     self::$_config = $config;
 }