コード例 #1
0
ファイル: Model.php プロジェクト: bstats/b-stats
 public static function get() : Model
 {
     if (isset(self::$instance)) {
         return self::$instance;
     }
     self::$instance = new Model();
     return self::$instance;
 }
コード例 #2
0
ファイル: Model.php プロジェクト: meniam/model
 /**
  * @param Mysql $connection
  * @param null $connectionName
  * @param bool $isDefault
  * @throws ErrorException
  */
 public static function addDb(Mysql $connection, $connectionName = null, $isDefault = false)
 {
     $connectionName = $connectionName ? (string) $connectionName : 'db';
     if (isset(self::$connections[$connectionName])) {
         throw new ErrorException("Connection with the same name already registered");
     }
     self::$connections[$connectionName] = $connection;
     if ($isDefault) {
         self::$defaultConnection = $connection;
     }
 }