getting nid after inserting node by drupal_execute()

farzan - October 25, 2007 - 04:18

Hello,

I use drupal_execute() for inserting a new node. After insertion, how can i get the nid of new node? I tried to use a query like this:

select
    nid
from
    {node}
where
    [some conditions based on node data, like node title]
order by
    nid desc
limit 1

But I do not have a good feeling about this way. Is there any other way to retrieve the nid of inserted node?

drupal_execute returns the value of the nid

rajenho - October 6, 2008 - 13:55

drupal_execute returns a string like node/ where nid is the value of the node that was just created. You can use it.

 
 

Drupal is a registered trademark of Dries Buytaert.