newFromContext() public static method

Creates a Database object, opens the connection and returns the instance.
public static newFromContext ( TestSwarmContext $context )
$context TestSwarmContext
Example #1
0
 /**
  * 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;
 }