2016-03-27 3 views
-1

ビューをレンダリングする際にクエリのカウントを表示する方法を教えてください。私はPHPのバージョンについてレンダリング中にSqlを数えるレール

Processed with 8 queries. 

などのテキストメッセージを表示したいと思い

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)これだけを開発したい場合は? –

答えて

関連する問題