Get UC product attributes using Views Global PHP I tried using below code in Views > Global PHP field.

&lt;?php

$request = db_query("SELECT data FROM {uc_order_products } WHERE order_id= $row-&gt;order_id")-&gt;fetchField();
$att =  $request;

$data = unserialize($att);

if (is_array($data['attributes'])) {
  foreach ($data['attributes'] as $attribute =&gt; $option) {
    echo $attribute . ':   ' . implode(', ', (array)$option) . '&lt;br&gt;';
  }
}

?&gt;


Adding above code I get the below error :


  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


Also how do I print each attribute in a different field?
If you use a variable in your request, it's preferable to use it like this : WHERE o.order_id = :oid', array(':oid' => $row->order_id).

So I guess it would be : 

$request = db_query('SELECT o.data FROM {uc_order_products} o WHERE o.order_id= :oid', array(':oid' =&gt; $row-&gt;order_id)')-&gt;fetchField();


To have different fields, you can do this processus for each field, by using multiple PhP fields in your view. But to rationalize requests, I would first do that request in the "setup code"  and set all your data in the $static variable.