Get node title from nid without using node_load($nid) in Drupal7

Get node title without using node_load($nid).
 

function get_node_title($nid) {
  $node_title = db_select('node', 'n')
      ->fields('n',array('title'))
      ->condition('nid',$nid,'=')
      ->execute()
      ->fetchField();
  return $node_title;
}

 

Tags

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
5 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.