Is possible to dump a query made on a twig template for a statement like this one for example:
craft.entries.section('homepage')
Can we some how see the actual SQL query ?
You can see each SQL query that is run for a page by turning devMode on and opening your console to read the 'Profiling Summary Report'.
You can see a total query count and each query beings with system.db.CDbCommand.query
.
I'd advise maybe isolating the twig code on its own template to avoid having to work out which query was a result of the twig code you're after.
Query log
.The 'Profiling Summary Report' is much easier cause no extra plugin is needed.
In Craft 3 you can use getRawSql()
at the end of the element query.
{% set entries = craft.entries.section('blog').getRawSql() %}
{{ entries }}