从fetched数组中显示值

时间:2016-09-14 05:55:25

标签: php arrays drupal

我想显示来自数据库的fetched数组的值我想只显示field_data_field_videoicon_node_entity_type

global $user;
$uid = $user->uid;
$result = db_query("SELECT node.title AS node_title, node.nid AS nid,  node.created AS node_created,  'node' AS field_data_field_videoicon_node_entity_type, 'node' AS field_data_field_customername_node_entity_type
FROM {node} node LEFT JOIN {field_data_field_customervideo} field_data_field_customervideo ON node.nid = field_data_field_customervideo.entity_id AND field_data_field_customervideo.entity_type = 'node' WHERE (( (node.status = 1 OR (node.uid = 1 AND 1 <> 0 AND 1 = 1) OR 1 = 1) AND (node.type IN  ('customerspeach')) )) ORDER BY node_created DESC LIMIT 3 OFFSET 0")->fetchAll(); 
// Printing result.
print_r($result);

$ result returns

Array ( 
    [0] => stdClass Object ( 
        [node_title] => client speach 2 
        [nid] => 65 
        [node_created] => 1473758768 
        [field_data_field_videoicon_node_entity_type] => node
        [field_data_field_customername_node_entity_type] => node 
    ) 
    [1] => stdClass Object ( 
        [node_title] => Customer Speak 
        [nid] => 62
        [node_created] => 1472720228
        [field_data_field_videoicon_node_entity_type] => node
        [field_data_field_customername_node_entity_type] => node 
    ) 
)

1 个答案:

答案 0 :(得分:1)

这是对象数组。您可以使用->箭头符号检索数据。

foreach($result as $data){
    echo $data -> field_data_field_videoicon_node_entity_type;
}