srv as $srv_name => $db_obj) { $log .= !empty($db_obj->dbg) ? get_sql_log_html($db_obj, "database: $srv_name [{$db_obj->engine}]") : ''; } foreach ($CACHES->obj as $cache_name => $cache_obj) { if (!empty($cache_obj->db->dbg)) { $log .= get_sql_log_html($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]"); } elseif (!empty($cache_obj->dbg)) { $log .= get_sql_log_html($cache_obj, "cache: $cache_name [{$cache_obj->engine}]"); } } $log .= !empty($sphinx) ? get_sql_log_html($sphinx, '$sphinx') : ''; if (!empty($datastore->db->dbg)) { $log .= get_sql_log_html($datastore->db, 'cache: datastore ['.$datastore->db->engine.']'); } else if(!empty($datastore->dbg)) { $log .= get_sql_log_html($datastore, 'cache: datastore ['.$datastore->engine.']'); } return $log; } function get_sql_log_html ($db_obj, $log_name) { $log = ''; foreach ($db_obj->dbg as $i => $dbg) { $id = "sql_{$i}_". mt_rand(); $sql = short_query($dbg['sql'], true); $time = sprintf('%.4f', $dbg['time']); $perc = @sprintf('[%2d]', $dbg['time']*100/$db_obj->sql_timetotal); $info = !empty($dbg['info']) ? $dbg['info'] .' ['. $dbg['src'] .']' : $dbg['src']; $log .= '' . '
' . ''. $time .' ' . ''. $perc .'' . ' ' . ''. $sql .'' . ' # '. $info .' ' . '
' . "\n"; } return '
'. $log_name .'
'. $log .' '; }