The example in this article describes how cakephp prints sql statements. Share it with everyone for your reference. The specific implementation method is as follows:
Copy the following statement into your code, you can print out all the sql statements before this:
$sources = ConnectionManager::sourceList(); if (!isset($logs)): $logs = array(); foreach ($sources as $source): $db =& ConnectionManager::getDataSource($source); if (!$db->isInterfaceSupported('getLog')): continue; endif; $logs[$source] = $db->getLog(); endforeach; endif;
I hope this article will be helpful to everyone’s PHP programming based on the cakePHP framework.