Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5962139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:03:48+00:00 2026-05-22T19:03:48+00:00

i am new to drupal 7. $sql = SELECT nid, title FROM {node} n

  • 0

i am new to drupal 7.

$sql = "SELECT nid, title FROM {node} n
    WHERE nid $sql_op %d
    AND type IN (" . implode(',', $quoted_types) . ")
    AND status = 1
    ORDER BY nid $order
    LIMIT 1";
  $result = db_query($sql, $current_node->nid, $type);
  $data = db_fetch_object($result);

how to put the above sql query upgrade to drupal 7 thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:03:49+00:00Added an answer on May 22, 2026 at 7:03 pm

    This looks like this for D7:

    $result = db_select('node', 'n')
      ->fields('n', array('nid', 'title'))
      ->condition('n.nid', $current_node->nid, $sql_op)
      ->condition('type', $type)
      ->condition('status', 1)
      ->orderBy('nid', $order)
      ->range(0, 1)
      ->execute();
    
    $data = $result->fetchObject();
    

    Untested, of course, so report back if this works. Also make sure that you use the correct types, not sure why the D6 version uses an IN statement for the type but then only has a single $type. Note that in the above code, you can either pass a single value or an array of values to condition(), both works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you create a new content type in Drupal using the Content Creation Kit,
Update I'm new a drupal developer, I have retrieved my node 'Student' and 'Internships'.
I'm new to extending Drupal, though I've done similar kinds of things for other
The new extensions in .Net 3.5 allow functionality to be split out from interfaces.
Preface: Yes, I've read: http://drupal.org/node/547518 I am writing 'foo' module for Drupal6, where I
I have a fairly new drupal installation with a few hundred nodes. I moved
I did a new Drupal theme for my site based on the Zen theme.
i'm new to drupal views. More link not displayed with my view block. i
I'm new to Drupal and am experiencing this strange problem with my testing Drupal
I'm currently working on a Drupal site (I'm fairly new to Drupal) and need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.