$query = $adapter->getProfiler()->getLastQueryProfile()->getQuery(); //print last executed query foreach ($adapter->getProfiler()->getLastQueryProfile()->getQueryParams() as $k => $v) { $query = $query = str_replace($k, "'{$v}'", $query); } var_dump($query);
A more complete example:
$adapter = Mage::getSingleton('core/resource')->getConnection('core_write'); $adapter->getProfiler()->setEnabled(true); //enable profiler // Do database stuff $number = 10; $profiles = $adapter->getProfiler()->getQueryProfiles(); $profiles = array_slice($profiles, count($profiles)-$number, $number); foreach ($profiles as $profile) { $query = $profile->getQuery(); //print last executed query foreach ($profile->getQueryParams() as $k => $v) { $query = $query = str_replace($k, "'{$v}'", $query); $query = preg_replace('/\?/', $v, $query); } var_dump($query); }
0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment