dibi::isConnected PHP Method

isConnected() public static method

Returns TRUE when connection was established.
public static isConnected ( ) : boolean
return boolean
    public static function isConnected()
    {
        return self::$connection !== NULL && self::$connection->isConnected();
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Initialise the driver.
  *
  * Expects options containing a key 'SQL_DRIVER' with constructor values from dibi::connect()
  *
  * Example:
  * 		"SQL_DRIVER" => Array(
  *		'driver' => 'sqlite',
  *			'file' => "./server/ajxp.db"
  *		)
  *
  * Example 2:
  * 		"SQL_DRIVER" => Array(
  * 		'driver' => 'mysql',
  * 		'host' => 'localhost',
  * 		'username' => 'root',
  * 		'password' => '***',
  * 		'database' => 'dbname'
  * 		)
  *
  * @see AbstractConfDriver#init($options)
  */
 public function init($options)
 {
     parent::init($options);
     $this->sqlDriver = AJXP_Utils::cleanDibiDriverParameters($options["SQL_DRIVER"]);
     try {
         if (!dibi::isConnected()) {
             dibi::connect($this->sqlDriver);
         }
         if (AJXP_SERVER_DEBUG && AJXP_VERSION_DB != "##DB_VERSION##") {
             $res = dibi::query("select MAX(db_build) from [ajxp_version]");
             if (!empty($res)) {
                 $dbVersion = intval($res->fetchSingle());
                 $current = intval(AJXP_VERSION_DB);
                 if ($dbVersion > 0 && $dbVersion < $current) {
                     // We need to upgrade now!
                     error_log("[Pydio] DB Upgrade Required! You may encounter strange issues. Make sure to manually apply the DB update.");
                     $this->logError("[DB]", "DB Upgrade Required! You may encounter strange issues. Make sure to manually apply the DB update.");
                 }
             }
         }
     } catch (DibiException $e) {
         //throw $e;
         echo get_class($e), ': ', $e->getMessage(), "\n";
         exit(1);
     }
 }
All Usage Examples Of dibi::isConnected