/** * Returns an instance of the Database. * * @return Database */ public static function getDatabaseInstance() { if (is_null(self::$db)) { self::$db = Database::getInstance(); } return self::$db; }
/** * Executes the built query. * * @return \Queryer\Driver\DatabaseDriverResult */ public function execute() { // Is someone mocking us? Well... that's not very nice! if (!is_null(self::$mocker)) { return self::$mocker->execute($this->options); } // Otherwise we'll hit up the driver. return Database::getInstance()->execute($this->options); }
/** * Tests to ensure that a database exception is thrown when the engine doesn't exist. */ public function testGetInstanceException() { $engineName = 'DoesNotExist'; $this->setExpectedException('\\Queryer\\Exception\\DatabaseException', sprintf('The database driver %s was not found (attempted to autoload "%s").', htmlspecialchars(ucfirst(strtolower($engineName))), htmlspecialchars(Database::getDriverClassName($engineName))), DatabaseException::DRIVER_NOT_FOUND); // Tell it to use a nonexistent engine. Database::setEngineName($engineName); // Then it should throw an Exception. Database::getInstance(); }