src/Neutrino/Support/Db.php
public static function getQueries(\Closure $callback, $pretend = false)
    {
        $db = Di::getDefault()->get(Services::DB);

        if (is_null($em = $db->getEventsManager())) {
            $db->setEventsManager($em = new Manager());
        }

        $queries = [];

        $listener = function (Event $event, Adapter $db) use (&$queries, $pretend) {
            $queries[] = $db->getRealSQLStatement();

            if ($pretend && $event->isCancelable()) {
                $event->stop();
            }

            return !$pretend;
        };

        $em->attach(Events\Db::BEFORE_QUERY, $listener);

        $callback();

        $em->detach(Events\Db::BEFORE_QUERY, $listener);

        return $queries;
    }
public static function getQueries(\Closure $callback, $pretend = false)
    {
        $db = Di::getDefault()->get(Services::DB);

        if (is_null($em = $db->getEventsManager())) {
            $db->setEventsManager($em = new Manager());
        }

        $queries = [];

        $listener = function (Event $event, Adapter $db) use (&$queries, $pretend) {
            $queries[] = $db->getRealSQLStatement();

            if ($pretend && $event->isCancelable()) {
                $event->stop();
            }

            return !$pretend;
        };

        $em->attach(Events\Db::BEFORE_QUERY, $listener);

        $callback();

        $em->detach(Events\Db::BEFORE_QUERY, $listener);

        return $queries;
    }
Return queries randed behind callback.

@param \Closure $callback
@param bool     $pretend

@return array