That solution work in Cake 2.0 only if you have debug mode 2 or more. If you are in Cake 1.x you should do this
function getLastQuery()
{
$dbo = $this->getDatasource();
$logs = $dbo->_queriesLog;
return end($logs);
}
that code should go on
app/app_model.php so is accesible for all your models.