src/Dev/Install/MySQLDatabaseConfigurationHelper.php
public function checkDatabasePermissionGrant($database, $permission, $grant)
    {
        // Filter out invalid database names
        if (!$this->checkValidDatabaseName($database)) {
            return false;
        }

        // Escape all valid database patterns (permission must exist on all tables)
        $sqlDatabase = addcslashes($database, '_%'); // See http://dev.mysql.com/doc/refman/5.7/en/string-literals.html
        $dbPattern = sprintf(
            '((%s)|(%s)|(%s)|(%s))',
            preg_quote("\"$sqlDatabase\".*"), // Regexp escape sql-escaped db identifier
            preg_quote("\"$database\".*"),
            preg_quote('"%".*'),
            preg_quote('*.*')
        );
        $expression = '/GRANT[ ,\w]+((ALL PRIVILEGES)|(' . $permission . '(?! ((VIEW)|(ROUTINE)))))[ ,\w]+ON ' . $dbPattern . '/i';
        return preg_match($expression, $grant);
    }
public function checkDatabasePermissionGrant($database, $permission, $grant)
    {
        // Filter out invalid database names
        if (!$this->checkValidDatabaseName($database)) {
            return false;
        }

        // Escape all valid database patterns (permission must exist on all tables)
        $sqlDatabase = addcslashes($database, '_%'); // See http://dev.mysql.com/doc/refman/5.7/en/string-literals.html
        $dbPattern = sprintf(
            '((%s)|(%s)|(%s)|(%s))',
            preg_quote("\"$sqlDatabase\".*"), // Regexp escape sql-escaped db identifier
            preg_quote("\"$database\".*"),
            preg_quote('"%".*'),
            preg_quote('*.*')
        );
        $expression = '/GRANT[ ,\w]+((ALL PRIVILEGES)|(' . $permission . '(?! ((VIEW)|(ROUTINE)))))[ ,\w]+ON ' . $dbPattern . '/i';
        return preg_match($expression, $grant);
    }
public function checkDatabasePermissionGrant ( $ database , $ permission , $ grant ) { // Filter out invalid database names if ( ! $ this -> checkValidDatabaseName ( $ database ) ) { return false ; } // Escape all valid database patterns (permission must exist on all tables) $ sqlDatabase = addcslashes ( $ database , '_%' ) ; // See http://dev.mysql.com/doc/refman/5.7/en/string-literals.html $ dbPattern = sprintf ( '((%s)|(%s)|(%s)|(%s))' , preg_quote ( "\"$sqlDatabase\".*" ) , // Regexp escape sql-escaped db identifier preg_quote ( "\"$database\".*" ) , preg_quote ( '"%".*' ) , preg_quote ( '*.*' ) ) ; $ expression = '/GRANT[ ,\w]+((ALL PRIVILEGES)|(' . $ permission . '(?! ((VIEW)|(ROUTINE)))))[ ,\w]+ON ' . $ dbPattern . '/i' ; return preg_match ( $ expression , $ grant ) ; }
Checks if a specified grant proves that the current user has the specified
permission on the specified database

@param string $database Database name
@param string $permission Permission to check for
@param string $grant MySQL syntax grant to check within
@return boolean
Checks if a specified grant proves that the current user has the specified permission on the specified database