示例#1
0
 /**
  * @return Database\Connection
  */
 public static function GetConnection()
 {
     if (is_null(self::$connection)) {
         // Connect to database
         $credentials = \App\Config\Database::GetData();
         self::$connection = new Database\Connection($credentials['dsn'], $credentials['username'], $credentials['password'], isset($credentials['options']) ? $credentials['options'] : null);
         // Set exceptions error mode
         self::$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     }
     return self::$connection;
 }
示例#2
0
文件: Model.php 项目: raframework/ra
 public function __construct($database, $table = null)
 {
     $this->database = $database;
     $this->table = $table;
     $this->manager = Manager::getInstance(Config\Database::conf());
 }