Reputation: 973
I am using cakephp framework. I need SQL for following statement:
$vehicle = $this->Vehicle->find('all');
How can I do that?
Please guide me.
Thank you, Trupti
Upvotes: 0
Views: 318
Reputation: 3476
For Cakephp 1.x, you could use following code to get the last query
$dbo = $this->Vehicle->getDatasource();
$logs = $dbo->getLog();
$lastLog = end($logs['log']);
echo $lastLog['query'];
Alternatively, To get all the Queries executed in the Current HTTP Request, you can use the following code
$db =& ConnectionManager::getDataSource('default');
$db->showLog();
You have to set the Debug Mode to 2 for this to work.
Upvotes: 1