Views API

How to return the SQL Query code from any View?

I have been struggling for a few days after this

I need to return the SQL Query of a given view or from the current page

I finally figured out how, it is quite simple with only 2 lines of code:

$view = views_get_view('nomedaview'); // or views_get_page_view() for the current page view

$query_string = (string) $view->build_info[&query];

That's all !!!

Como pegar o código SQL de uma View?

Estive furiosamente procurando isto nos últimos 3+ dias
Enfim matei a charada!! E para o espanto da galera, apenas 2 linhas de código são necessárias: