Example #1
0
 private function getDatabaseConnection()
 {
     $dsn = "sqlite:{$this->database_location}";
     $username = "";
     $password = "";
     Connection::setDsn($dsn);
     Connection::setUsername($username);
     Connection::setPassword($password);
     return Connection::getInstance();
 }
 /**
  * Connects to a database within the Pluginizer realm :)
  *
  * @param string $file_name
  * @return string File Extension
  *
  * @todo WE SERIOUSLY NEED A BETTER WAY TO GET A CONNECTION TO THE DATABASE
  *  FROM THIS METHOD. WE USE PHP's Debug_Backtrace METHOD THAT's INCONSISTENT
  *  I Don't Know, but there's something we can do to improve how this method
  *  returns a connection object to our database. Maybe a specific config file?
  *  but that's extra work for developers.
  */
 public static function getDatabaseConnection()
 {
     /**
      * @var $current_module Gets the full URI of the module that's been worked on
      * @see ModuleUtility::getModuleURI() For an explanation of the getModuleURI method
      * @see ModuleUtility::getCurrentModule() See comment above
      */
     $current_module = ModuleUtility::getModuleURI(ModuleUtility::getCurrentModule(), "");
     $pdb = isset(glob($current_module . "/configs/*.pdb")[0]) ? glob($current_module . "/configs/*.pdb")[0] : null;
     $dsn = "sqlite:{$pdb}";
     $username = "";
     $password = "";
     Connection::setDsn($dsn);
     Connection::setUsername($username);
     Connection::setPassword($password);
     return Connection::getInstance();
 }