public static function newFromContext(TestSwarmContext $context) { $dbConf = $context->getConf()->database; $db = new self(); $db->context = $context; $db->host = $dbConf->host; $db->username = $dbConf->username; $db->password = $dbConf->password; $db->dbname = $dbConf->database; $db->open(); return $db; }
/** * Get the Database object * @return Database */ public function getDB() { if ($this->db === null) { // Check if there is a database lock $lock = $this->dbLock(); if ($lock) { throw new SwarmException("Database is temporarily locked for maintenance (since: " . strftime("%c", $lock) . ")"); } $this->db = Database::newFromContext($this); } return $this->db; }