lithium\data\source\database\adapter\MySql::enabled PHP Method

enabled() public static method

Check for required PHP extension, or supported database feature.
public static enabled ( string $feature = null ) : boolean
$feature string Test for support for a specific feature, i.e. `"transactions"` or `"arrays"`.
return boolean Returns `true` if the particular feature (or if MySQL) support is enabled, otherwise `false`.
    public static function enabled($feature = null)
    {
        if (!$feature) {
            return extension_loaded('pdo_mysql');
        }
        $features = array('arrays' => false, 'transactions' => false, 'booleans' => true, 'schema' => true, 'relationships' => true, 'sources' => true);
        return isset($features[$feature]) ? $features[$feature] : null;
    }

Usage Example

 /**
  * Skip the test if a MySQL adapter configuration is unavailable and preload test data.
  */
 public function skip()
 {
     $this->skipIf(!MySql::enabled(), 'MySQL Extension is not loaded');
     $dbConfig = Connections::get('test', array('config' => true));
     $hasDb = isset($dbConfig['adapter']) && $dbConfig['adapter'] == 'MySql';
     $message = 'Test database is either unavailable, or not using a MySQL adapter';
     $this->skipIf(!$hasDb, $message);
     $this->db = new MySql($dbConfig);
 }
All Usage Examples Of lithium\data\source\database\adapter\MySql::enabled