Drupal 7 Execute a mysql sql query in Views using Views PHP I'm trying to do a custom sql query in Views for Drupal 7 and I have the following code in my views php, but I'm not sure if I'm doing this correctly.

&lt;?php $xx = db_query('SELECT * FROM acl_node INNER JOIN acl_user ON acl_node.acl_id=acl_user.acl_id INNER JOIN users ON acl_user.uid=users.uid WHERE nid=201');

print_r($xx);
?&gt;


After running that I get a big array, but none of the data in it. I tested the sql query and it is indeed working via my sql builder tool.
You must avoid using php in UI.

As a solution
  - Either you can override the views template.
  - Or you can try implmenting hook_views_pre_render.(Reference https://knackforge.com/blog/sivaji/how-alter-views-field-output-programmatically)

Now, about fetching the results from query result object.  

Other than iterating through the result set, there are other ways to fetch results.