phalcon常用语法

打印SQL

//在config/service.php中注册服务    
$di->set(
    'profiler',
    function () {
        return new PhalconDbProfiler();
    },
    true
);


//在controller中输出如下代码
$profiles = $this->di->get('profiler')->getProfiles();
//遍历输出
foreach ($profiles as $profile) {
    echo "SQL语句: ", $profile->getSQLStatement(), "<br/>";
    //echo "开始时间: ", $profile->getInitialTime(), "
";
    //echo "结束时间: ", $profile->getFinalTime(), "
";
    //echo "消耗时间: ", $profile->getTotalElapsedSeconds(), "
";
}
//最后语句
//echo $this->di->get('profiler')->getLastProfile()->getSQLStatement();
die;
原文地址:https://www.cnblogs.com/qq917937712/p/9481370.html