AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
# Class Phalcon\\Db\\Profiler # Class **Phalcon\\Db\\Profiler** Instances of Phalcon\\Db can generate execution profiles on SQL statements sent to the relational database. Profiled information includes execution time in miliseconds. This helps you to identify bottlenecks in your applications. ``` <pre class="calibre14">``` <?php $profiler = new \Phalcon\Db\Profiler(); //Set the connection profiler $connection->setProfiler($profiler); $sql = "SELECT buyer_name, quantity, product_name FROM buyers LEFT JOIN products ON buyers.pid=products.id"; //Execute a SQL statement $connection->query($sql); //Get the last profile in the profiler $profile = $profiler->getLastProfile(); echo "SQL Statement: ", $profile->getSQLStatement(), "\n"; echo "Start Time: ", $profile->getInitialTime(), "\n"; echo "Final Time: ", $profile->getFinalTime(), "\n"; echo "Total Elapsed Time: ", $profile->getTotalElapsedSeconds(), "\n"; ``` ``` ### Methods public <a class="calibre6 pcalibre1" href="">*Phalcon\\Db\\Profiler*</a>**startProfile** (*string* $sqlStatement, \[*unknown* $sqlVariables\], \[*unknown* $sqlBindTypes\]) Starts the profile of a SQL sentence public **stopProfile** () Stops the active profile public **getNumberTotalStatements** () Returns the total number of SQL statements processed public **getTotalElapsedSeconds** () Returns the total time in seconds spent by the profiles public **getProfiles** () Returns all the processed profiles public **reset** () Resets the profiler, cleaning up all the profiles public **getLastProfile** () Returns the last profile executed in the profiler | - [索引](# "总目录") - [下一页](# "Class Phalcon\Db\Profiler\Item") | - [上一页](# "Class Phalcon\Db\Index") | - [API Indice](#) »