Hello,

How do I easily extract a specific node id from the db?

Comments

mooffie’s picture

Node ID is just a number. I'm not sure what there is to extract in a number.

Do you mean, "How do I load a node from the DB, based on its node ID?"

If so, the general answer is $node = node_load(1234); (replace '1234' with the node ID). Then, for example, you can access the various field of this node with $node->title, $node->body, $node->created, etc. You can get a rendering of this node with node_view($node);.

See http://api.drupal.org/ and the hanbooks here.

DayShallCome’s picture

Well, what I'm doing is inserting a new node into the db via drupal_excute, and I need to know what the nid of that new node is.

rvk’s picture

Was looking for this info as well. I think you can get the nid from the URL when editing the node (of course if you have path-module switched of it becomes even easier. But I wonder why it's not listed in a more obvious place for content admins.
Does anyone know another way?
Thanks
Robin