PMA\libraries\Util::profilingSupported PHP Method

profilingSupported() public static method

Verifies if current MySQL server supports profiling
public static profilingSupported ( ) : boolean
return boolean whether profiling is supported
    public static function profilingSupported()
    {
        if (!self::cacheExists('profiling_supported')) {
            // 5.0.37 has profiling but for example, 5.1.20 does not
            // (avoid a trip to the server for MySQL before 5.0.37)
            // and do not set a constant as we might be switching servers
            if (defined('PMA_MYSQL_INT_VERSION') && $GLOBALS['dbi']->fetchValue("SELECT @@have_profiling")) {
                self::cacheSet('profiling_supported', true);
            } else {
                self::cacheSet('profiling_supported', false);
            }
        }
        return self::cacheGet('profiling_supported');
    }

Usage Example

/**
 * Returns JSon for query_analyzer
 *
 * @return array
 */
function PMA_getJsonForQueryAnalyzer()
{
    $return = array();
    if (mb_strlen($_REQUEST['database'])) {
        $GLOBALS['dbi']->selectDb($_REQUEST['database']);
    }
    if ($profiling = PMA\libraries\Util::profilingSupported()) {
        $GLOBALS['dbi']->query('SET PROFILING=1;');
    }
    // Do not cache query
    $query = preg_replace('/^(\\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query']);
    $GLOBALS['dbi']->tryQuery($query);
    $return['affectedRows'] = $GLOBALS['cached_affected_rows'];
    $result = $GLOBALS['dbi']->tryQuery('EXPLAIN ' . $query);
    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
        $return['explain'][] = $row;
    }
    // In case an error happened
    $return['error'] = $GLOBALS['dbi']->getError();
    $GLOBALS['dbi']->freeResult($result);
    if ($profiling) {
        $return['profiling'] = array();
        $result = $GLOBALS['dbi']->tryQuery('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING' . ' WHERE QUERY_ID=1 ORDER BY seq');
        while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
            $return['profiling'][] = $row;
        }
        $GLOBALS['dbi']->freeResult($result);
    }
    return $return;
}
All Usage Examples Of PMA\libraries\Util::profilingSupported
Util