打印SQLphp
//在config/service.php中註冊服務 $di->set( 'profiler', function () { return new \Phalcon\Db\Profiler(); }, true ); //在controller中輸出以下代碼 $profiles = $this->di->get('profiler')->getProfiles(); //遍歷輸出 foreach ($profiles as $profile) { echo "SQL語句: ", $profile->getSQLStatement(), "<br/>"; //echo "開始時間: ", $profile->getInitialTime(), "\n"; //echo "結束時間: ", $profile->getFinalTime(), "\n"; //echo "消耗時間: ", $profile->getTotalElapsedSeconds(), "\n"; } //最後語句 //echo $this->di->get('profiler')->getLastProfile()->getSQLStatement(); die;