Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2. function eb_mine_views_query_alter(&$view, &$query) {
  3. if ($view->name == 'statuser') {
  4. dsm($query, 'before');
  5. $query->where[0]['type'] = 'OR';
  6. dsm($query, 'after');
  7. }
  8. }
  9. ?>
  10.  
  11. SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
  12. FROM
  13. {node} node
  14. INNER JOIN {taxonomy_index} taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = :views_join_condition_0
  15. INNER JOIN {taxonomy_index} taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = :views_join_condition_1
  16. WHERE ((( (taxonomy_index_value_0.tid = :db_condition_placeholder_2) )**AND**( (taxonomy_index_value_1.tid = :db_condition_placeholder_3) )))
  17. ORDER BY node_created DESC
  18.  
  19. SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
  20. FROM node node
  21. OUTER JOIN taxonomy_index taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = '9'
  22. OUTER JOIN taxonomy_index taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = '6'
  23. WHERE ((( (taxonomy_index_value_0.tid = '9') )OR( (taxonomy_index_value_1.tid = '6') )))
  24. ORDER BY node_created DESC LIMIT 5 OFFSET 0;
  25.  
  26. SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
  27. FROM node node
  28. LEFT OUTER JOIN taxonomy_index taxonomy_index_value_0 ON node.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = '9'
  29. LEFT OUTER JOIN taxonomy_index taxonomy_index_value_1 ON node.nid = taxonomy_index_value_1.nid AND taxonomy_index_value_1.tid = '6'
  30. WHERE ((( (taxonomy_index_value_0.tid = '9') )OR( (taxonomy_index_value_1.tid = '6') )))
  31. ORDER BY node_created DESC LIMIT 5 OFFSET 0;
  32.  
  33. function custom_views_query_alter(&$view, &$query) {
  34. if($view->name == "tag_cloud"){
  35. print_r($query);// before modifying the query.
  36. $query->table_queue['taxonomy_index']['join']->type = "LEFT OUTER JOIN";
  37. //sample field change where ever you want
  38. print_r($query);// after modifying the query .
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement