2016-03-27 68 views
-1

如何在呈现视图时显示查询计数。在渲染过程中计算Sql的轨迹

我想显示的短信像

Processed with 8 queries. 

对于PHP版本

function query($query) 
{ 
    //We increase the queries counter by 1 
    global $nb_queries,$timer_queries; 
    $nb_queries++; 
    //Execute the query and time the execution time 
    $beginning = timer(); 
    //Execute the query and save the result in a variable 
    $req_return = mysql_query($query); 
    //We add the query duration to the total 
    $timer_queries += round(timer()-$beginning,6); 
    return $req_return; 
} 

我怎样才能做到在轨

+0

您正在使用哪个数据库系统? –

+0

对于开发是SQLite,将在生产中使用MySQL – AlexLeung

+0

您是否考虑使用[rails-footnotes](https://github.com/josevalim/rails-footnotes)或[rails_panel](https://github.com/ dejan/rails_panel)如果你只想在开发中使用它? –

回答