views_query_alter Doesn't Change Query and Table in views
My purpose PROBLEM: The views reads my function but only return message from drupal_set_message command. And do not make any changes to Initial query and table. Here is my function: function my_module_views_query_alter(&$view, &$query) { if ($view->name == 'custom_views') { drupal_set_message("Hello"); $query =db_select('users','u'); $query -> addField('u','uid','Customer id'); $query -> addField('u','mail','Customer Email'); $results = $query -> execute(); } } Here are things that i've confirmed:
1. Flush all caches. More details about my question is on http://stackoverflow.com/questions/39379002/views-query-alter-doesnt-change-my-query-and-table-in-views Thankyou for reading and i appreciate your help. :) 问题细节请点击上面我在stackoverflow 上放的问题。谢谢各位愿意帮我的朋友。 |
|
weihaolLv 5
|
1 个回答
"If you have the $query variable, then you can do something like drupal_set_message((string) $query) before you run $query->execute(). Otherwise you can download and enable the Devel module and call dpq($query)."
( source: https://api.drupal.org/api/drupal/includes!database!database.inc/functio... )
garychicken23Lv 5