When using the Views PHP module you can return all available fields for the view by adding a 'Global: PHP' field and adding the below code to the 'Output code':
<?php print_r($data); ?>
This will return something similar to the below for a view that is only set to display node titles:
PHP: stdClass Object ( [node_title] => Here is my title 1 [nid] => 4 [node_created] => 1371732854 ) PHP: stdClass Object ( [node_title] => Here is my title 2 [nid] => 3 [node_created] => 1371728383 ) PHP: stdClass Object ( [node_title] => Here is my title 3 [nid] => 2 [node_created] => 1371637708 )
You can then print out values using your 'Global: PHP' field like this:
<?php print_r($data->node_title); ?>
Using a 'Global: PHP' field it is also possible to print values directly from your database using MySQL queries. See this link for a good example of how to do this using db_query.
Drupal version:

Justin Chevallier
Avid Drupal site builder & user for +10 years.
Comments
Broken link to using SQL query in Views PHP
Looks like the link in your article is missing. Do you have a corrected one? Thx
Looks like the site has been decommissioned
I'll update the link. Here is another page with some examples: https://www.drupal.org/node/1686948
Add new comment