cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 get last query

Magento 2 get last query

Hi,

 

I want to get the last query executed. Ok, in a controller but if there's a different ways in different parts i appreciate full information.

 

This is what i did in Magento 1:

$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
$profiler->setEnabled(true);

// ...

Mage::log(print_r($profiler->getQueryProfiles(), true), null, 'queries.log', true);
$profiler->setEnabled(false);

 

Regards