Get nid from DB?

DayShallCome - April 23, 2007 - 05:05

Hello,

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

...

mooffie - April 23, 2007 - 09:40

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.

Well, what I'm doing is

DayShallCome - April 23, 2007 - 23:29

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.

Looking for the same info

rvk - May 23, 2007 - 11:33

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

 
 

Drupal is a registered trademark of Dries Buytaert.