Exemple #1
0
 /**
  * 
  * @return Page
  */
 public static function createInstance()
 {
     if (self::$inst == null) {
         self::$inst = new self(\Database\Db::getInstance());
     }
     return self::$inst;
 }
Exemple #2
0
 function __construct($id, $title, $text, $author, $type, $views, $date, $img)
 {
     parent::__construct($id, $title, $text);
     $this->author = $author;
     $db = \database\Db::getInstance();
     $pdo = $db->getDb();
     $category = new CategoryMapper($pdo);
     $this->type = $category->find($type);
     $this->views = $views;
     $this->date = $date;
     $this->img = $img;
 }
 /**
  * Registry constructor.
  * @param $db
  */
 public function __construct($db)
 {
     // Exemplo de injeção de dependência
     $this->db = Db::getInstance();
 }
Exemple #4
0
 /**
  * 设置服务对应队列存放数据库并进行实例化数据库实例
  */
 public function setDb()
 {
     $type = array_key_exists("type", $this->db_conf) ? $this->db_conf["type"] : DATA_TYPE_REDIS;
     $this->db = Db::getInstance($type, $this->db_conf);
 }