Piwik\DbHelper::isValidDbname PHP Method

isValidDbname() public static method

Database names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), plus(+), and dot(.) will be accepted. File names beginning with anything but a-Z or 0-9 will be rejected (including .htaccess for example). File names containing anything other than above mentioned will also be rejected (file names with spaces won't be accepted).
public static isValidDbname ( string $dbname ) : boolean
$dbname string
return boolean
    public static function isValidDbname($dbname)
    {
        return 0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z0-9\\_\\.\\-\\+]*))$/D', $dbname);
    }

Usage Example

Esempio n. 1
0
 function validateOwner()
 {
     $prefix = $this->owner->getValue();
     return empty($prefix) || DbHelper::isValidDbname($prefix);
 }