What's that File (layout)?
There are many different ways to figure out what information the node table contains.
- You could use
dsm($node);in an appropriate place in your code, assuming you have the Devel module installed.
- You could also use a poor man's version of dsm, a la
drupal_set_message('<pre>' . print_r($node, 1) . '</pre>');.
- You might think to take a look at the Node template file.
- On the other hand, you might ssh into a server and do something like
mysql -u someuser --database=somedatabase -pfollowed by
DESC node. Some of you might even have done
drush sqlcinstead of entering the mysql sequence.
But, most of those options would require you to leave your browser. And maybe the node.tpl.php doesn't quite make things clear for you. How about looking at the code that defines the table?
Some of you may be saying, "But then I'd still have to go out to a terminal and do a
drush dl drupal." Alas, there is another way to approach looking at code, that I use quite regularly. I'll walk you through the steps for this particular example.
- Navigate to the project page.
- Look in the right sidebar and click on the View commits link.
- Click on any of the commit ids
- Strip out part of the path to take you to the project git repo. Of course, if you remember the pattern [I never do], you can just go directly to the repo without all those extra clicks.
- Scroll down the page to the section that says "heads."
- Choose one of the heads and click on the tree link.
- Next click on the modules link.
- Select node.
- Open up node.install and look at
While this post focused strictly on finding out the schema for the node table, the technique could be used to find out anything about what a project is doing, without having to leave your browser. In addition, it makes mention of a lot of other handy tools.
You may be wondering:
- "What is this devel module and what is dsm?"
- "What is drupal_set_message and what if I can't interrupt the program flow to print a message to the screen at that time?"
- "What is the Node template file and when would I use it?"
- "What is this drush sqlc and drush dl?"
All of those questions make for more blog posts!
If you'd like to read a post on one of those topics, or on some other topic, register an account (sorry commenting is still disabled for anonymous visitors) and leave a comment or shoot me a message through my contact form.
Thanks to Chris Miller for suggesting that I write this post.