views:

909

answers:

3

i m completly newbie to drupal i have designed a view and when i see the query in preview section

SELECT node.nid AS nid, node_data_field_crm_history_brokerid.field_crm_history_brokerid_value AS node_data_field_crm_history_brokerid_field_crm_history_brokerid_value, node.language AS node_language, node.type AS node_type, node.vid AS node_vid, node_data_field_crm_history_brokerid.field_crm_history_caseid_value AS node_data_field_crm_history_brokerid_field_crm_history_caseid_value, node_data_field_crm_history_brokerid.field_crm_history_dateadded_value AS node_data_field_crm_history_brokerid_field_crm_history_dateadded_value, node_data_field_crm_history_brokerid.field_crm_history_entrydesc_value AS node_data_field_crm_history_brokerid_field_crm_history_entrydesc_value FROM node node LEFT JOIN content_type_crm_history node_data_field_crm_history_brokerid ON node.vid = node_data_field_crm_history_brokerid.vid WHERE node.type in ('crm_history')

what vid mean here?

actually i need this because when i try to insert a simple rule to insert a row in the crm_history using this query

$result = db_query("INSERT INTO {content_type_crm_history} (vid, nid, field_crm_history_caseid_value, field_crm_history_brokerid_value, field_crm_history_dateadded_value, field_crm_history_entrydesc_value) VALUES (" . $node->nid . ", " . $node->vid . ", " . $caseid . ", " . $brokerid . ", " . $dateadded . ", '" . t($entrydesc) . "')");

it does populates in the database table but it doen't show in the view it shows only the content when i add in create content page

+3  A: 

From the Drupal node object reference page, node->vid is the revision id of the current version of the node.

Node content isn't stored directly in the node table but in the node_revisions table. There's a good explanation of the table structures on this page.

alxp
+1  A: 

vid is the revision id. In Drupal, every node can have multiple revisions. If you aren't using revisions, then the nid (node ID) will equal the vid.

Greg
But, when not using revisions, don't count on nid always equaling vid!
Greg
can any one give examples of query to insert data in to the content so that i can see the contents in the view.. urgent guys
rakeshakurathi
@rakeshakurathi - Look at the source code for Node Clone. One of the few things it does is insert new nodes, so it should be easy to locate the relevant code in its source. http://drupal.org/project/node_clone
Greg
+2  A: 

Unfortunately, vid can mean multiple things. That's not ideal, but I have not seen it causing problems (other than mild confusion now and then).

In the context of nodes, it means 'version id'. For every node in the node table, Drupal can save multiple versions in the node_revisions table. The version id is the unique identifier in the node_revisions table. (This is the vid you see in your query.)

In the context of taxonomy, vid means 'vocabulary id'. A vocabulary is a collection of related terms. Every vocabulary has a unique id.

In the context of the Views module, vid means 'view id'.

On a different note, you should not be adding nodes to the database with custom queries. The better method is to create a node object and let drupal write it to the database using node_save (http://api.drupal.org/api/function/node_save/6).

marcvangend

related questions