我是 cakephp 的新手,在回显最后一个查询时遇到问题。我想看看正在执行的 sql 查询是什么,因为它没有返回预期的结果。 cakephp的版本是1.2.6。 我尝试过以下代码
//$log = $this->Auction->getDataSource()->getLog(false, false); ( this does not work, maybe due to old version )
$log = $this->Auction->getDataSource()->showLog( false );
//debug($this->Auction->lastQuery()); ( same goes for this line. lastQuery is not working maybe due to old version)
debug( $log );
这行显示
(default) 0 query took ms Nr Query Error Affected Num. rows Took (ms) public_html/controllers/auctions_controller.php (line 416) (default) 0 query took ms Nr Query Error Affected Num. rows Took (ms)
但是我想要的是要查看的sql查询。
预先感谢您的帮助。
最佳答案
在 CakePHP 1.x 中,您想要的数据可以在 DataSource::_queriesLog 中访问。
$dbo = $this->getDatasource();
$logs = $dbo->_queriesLog;
return end($logs);
关于php - 如何在 cakephp 1.2.6 中回显最后一个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45728268/