Posted by jmolinas on January 27, 2012 at 11:09am
I'am currently doing a project involving cck and views, Sometimes you can’t always get the things you want by using views, so I came across this when i was looking for a way to use my own sql queries in combination with views. I created custom module just for my custom sql queries using this code seem to work with view 2 but not for views 3. Are there any changes is views api?
function custom_views_views_pre_execute(&$view) {
if($view->name=="sales_report_dev")
{
$view->build_info['query']=
"SELECT node.nid AS nid,
users.name AS users_name,
users.uid AS users_uid, SUM(node_data_field_sales_date.field_sales_quantity_value) AS node_data_field_sales_date_field_sales_quantity_value,
node.type AS node_type, node.vid AS node_vid FROM node node LEFT JOIN content_type_sales_report node_data_field_sales_date ON node.vid = node_data_field_sales_date.vid INNER JOIN users users ON node.uid = users.uid
WHERE (node.type in ('sales_report')) GROUP BY users.name
";
}
}Thanks

Comments
Change of Approach
You could just directly access the Drupal DB rather than deal with Views. Please see http://api.drupal.org/api/drupal/includes--database--database.inc/group/...
Jaypax Ginete
http://killertilapia.blogspot.com/
Actually I also tried SQL
Actually I also tried SQL queries, but can i also use it with exposed filters?