Hemanth's Scribes

web

Get Node Details From Drupal

Author Photo

Hemanth HM

Thumbnail

Get Node Details From Drupal

Currently I’m trying to migrate my blog from drupal to something must lighter, migrating data is indeed the first step!

A simple SQL statement was very useful to get the node details, which will be very useful in making a custom made CMS.

This is very tiny entry in my blog to remind me that the migration is still pending!

THE SQL CODE TO GET DRUPAL NODE DETAILS :

"SELECT node.nid as id,

         node.status as status, 
         revision.title as title, 
         revision.body as body 

FROM node_revisions as revision JOIN node as node ON node.nid = revision.nid WHERE node.status = 1 ORDER BY node.nid DESC ”;

The above got simple does the below :

  • Gets the id and status from node table.

  • Gets Title and body from revisions table.

  • For all linked node and revisions which is published (i.e status = 1 and ids are same).

  • Orders them by node id from the latest to oldest entries.

Hope this helps the one who is pawing at some raw Drupal data!

#javascript#linux
Author Photo

About Hemanth HM

Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.