Is there a good way to get at the query or query object programmatically?

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by robertdouglass on May 31, 2006 at 3:51pm

I want to get my hands on the query that gets called to generate a view. Possible after calling views_get_view?

Comments

Instead of using

Posted by karens on May 31, 2006 at 4:07pm

Instead of using views_build_view('page', ...) and then views_pre_view() you could call views_build_view('result', ....) which stops before generating the view itself and returns an $info array that has the final query and a $result object you can use db_fetch_object() on.

Wicked!

Posted by robertdouglass on May 31, 2006 at 8:20pm

Thanks Karen =)

Same code?

Posted by doublejosh on March 27, 2008 at 3:53am

Could I get some same code?

I've done this and it's still not working?

<?php
$view_name
= 'available'; //name of view
$view_args= array();
$view= views_get_view($view_name);
$view_object= views_build_view('result', $view, $view_args, FALSE);
$skills= db_fetch_object($view_object['query'])
print_r($skills);
?>

Sorry, the $query object is

Posted by merlinofchaos on March 27, 2008 at 5:17am

Sorry, the $query object is destroyed by the time views_build_view() returns. You won't be able to retrieve it from the outside.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /