How do I use views_pre_execute I am trying to run a subquery  through views and found this call. I cannot get it to work. Here is how I am using it

function module_name_custom_views_pre_execute(&amp;$view) {
    if($view-&gt;name=="view_name") {
            if($view-&gt;build_info['query_args'][1]==0) {
            $view-&gt;build_info['query']="my subquery";

                //echo ($view-&gt;build_info['query'] );
                //var_dump($view);
            }
    }
}


Without to test it I tried replacing the $view->build_info['query'] with the query generated in the view. Instead of a view result I get a blank page. Any other query I put in there myself results in a blank page as well. 

I am writing the queries like so:

$view->build_info['query']="SELECT nid FROM node WHERE node.status='1'";

So I am not assigning any array objects values but rather writing the query in as if I would in any other db call. Should I build the query through the means of creating an object?  So something like this to start:

["build_info"]=&gt; array(3) { 
    ["query"]=&gt; object(SelectQuery)#752 (21) { 
        ["fields":protected]=&gt; array(4) { 
            ["nid"]=&gt; array(3) { 
                ["field"]=&gt; string(3) "nid" 
                ["table"]=&gt; string(4) "node" 
                ["alias"]=&gt; string(3) "nid" } 
        ["node_created"]=&gt; array(3) { 
            ["field"]=&gt; string(7) "created" 
            ["table"]=&gt; string(4) "node" 
            ["alias"]=&gt; string(12) "node_created" } 
        ["og_og_membership_label"]=&gt; array(3) { 
            ["field"]=&gt; string(5) "label" 
            ["table"]=&gt; string(16) "og_og_membership" 
            ["alias"]=&gt; string(22) "og_og_membership_label" } 
        ["node_title"]=&gt; array(3) { 
            ["field"]=&gt; string(5) "title" 
            ["table"]=&gt; string(4) "node" 
            ["alias"]=&gt; string(10) "node_title" } }


Is there is another way to implement a subquery in views?

Using Drupal 7 Views 3
Also checkout http://drupal.org/sandbox/Fabianx/1184598 as this is adding a subquery to a view; which is exactly what your trying to do.