mysql - Sql query in drupal module - what is node? -
i running following query returns array of stcclass objects below:
$result = db_query('select node.title node_title, node.nid nid, node.created node_created, \'node\' field_data_my_field_node_entity_type {node} node (( (node.status = :status) , (node.type in (:type)) )) order node_created desc', array(':status'=>'1', ':type'=>'_my_content_type')); stdclass object ( [node_title] => sample title [nid] => 331 [node_created] => 1367500781 [field_data_my_field_node_entity_type] => node )
it returns array of stdclass objects. problem in field 'field_data_my_field_node_entity_type' have string 'node' because passed query string. don't know this, suppose can value there if have correct syntax.
any idea how query supposed work?
thanks in advance
you getting value because setting in sql query 'node' field_data_my_field_node_entity_type
.
if question how entity type node, node; there isn't field in "nodes" table contains value.
if added "field_data_my_field_node_entity_type" field 1 or more content types, , want content of field, need follow these steps, since content of node fields not contained in "node" table.
- get node id of nodes
- load nodes
node_load()
$result = db_query('select nid {node} ((status = :status) , (type in (:type)) order created desc', array(':status'=>'1', ':type'=>'_my_content_type'))->fetchall(pdo::fetch_assoc); foreach ($result $row) { $node = node_load($row['nid']); // access field $node->field_data_my_field_node_entity_type. }
Comments
Post a Comment