0

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

Trupti
  • 843
  • 2
  • 11
  • 28

1 Answers1

1

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.

ascsoftw
  • 3,466
  • 2
  • 15
  • 23