2016-03-27 72 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)如果你只想在開發中使用它? –

回答