示例#1
0
$collations = Sql::pSelectMapped('SHOW VARIABLES LIKE "%collation%"');
foreach ($collations as $ch_name => $val) {
    echo $ch_name . ' = ' . $val . '<br/>';
}
echo '<br/>';
// show MySQL query cache settings
$data = Sql::pSelectMapped('SHOW VARIABLES LIKE "%query_cache%"');
if ($data['have_query_cache'] == 'YES') {
    echo '<h2>Query cache settings</h2>';
    echo 'Type: ' . $data['query_cache_type'] . '<br/>';
    //valid values: ON, OFF or DEMAND
    echo 'Size: ' . formatDataSize($data['query_cache_size']) . ' (total size)<br/>';
    echo 'Limit: ' . formatDataSize($data['query_cache_limit']) . ' (per query)<br/>';
    echo 'Min result unit: ' . formatDataSize($data['query_cache_min_res_unit']) . '<br/>';
    echo 'Wlock invalidate: ' . $data['query_cache_wlock_invalidate'] . '<br/><br/>';
    // current query cache status
    $data = Sql::pSelectMapped('SHOW STATUS LIKE "%Qcache%"');
    echo '<h2>Query cache status</h2>';
    echo 'Hits: ' . formatNumber($data['Qcache_hits']) . '<br/>';
    echo 'Inserts: ' . formatNumber($data['Qcache_inserts']) . '<br/>';
    echo 'Queries in cache: ' . formatNumber($data['Qcache_queries_in_cache']) . '<br/>';
    echo 'Total blocks: ' . formatNumber($data['Qcache_total_blocks']) . '<br/>';
    echo '<br/>';
    echo 'Not cached: ' . formatNumber($data['Qcache_not_cached']) . '<br/>';
    echo 'Free memory: ' . formatDataSize($data['Qcache_free_memory']) . '<br/>';
    echo '<br/>';
    echo 'Free blocks: ' . formatNumber($data['Qcache_free_blocks']) . '<br/>';
    echo 'Lowmem prunes: ' . formatNumber($data['Qcache_lowmem_prunes']);
} else {
    echo '<h2>MySQL query cache is disabled</h2>';
}
示例#2
0
 /** Get statistics for specified poll */
 static function getStats($type, $id)
 {
     $q = 'SELECT t1.categoryName, ' . '(SELECT COUNT(*) FROM ' . self::$tbl_name . ' WHERE type = ? AND value = t1.categoryId) AS cnt' . ' FROM tblCategories AS t1' . ' WHERE t1.ownerId = ?';
     return Sql::pSelectMapped($q, 'ii', $type, $id);
 }