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 6905589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:12:09+00:00 2026-05-27T08:12:09+00:00

I have a module that programmatically adds a whole lot of nodes to my

  • 0

I have a module that programmatically adds a whole lot of nodes to my Drupal 7 site. To prevent duplicates I want to check whether the title of my newly created node doesn’t already exist in the system. There will never be a case where two nodes have the same name. I’ve tried using node_load(), but that doesn’t seem to allow me to load nodes based on a title.

I’m stumped on how to proceed, so I was wondering if somebody here could help me.

To summarize: How do I check whether a node with a certain title already exists?

Thanks.

  • 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-27T08:12:09+00:00Added an answer on May 27, 2026 at 8:12 am

    You could get all the node titles with a SQL query like:

     $row = db_query('SELECT nid FROM {node} WHERE title = :mytitle', array(':mytitle' => $myNewTitle))->fetchField();
     if(!isset($row['nid'])) {
        //safe to continue
     } else {
        //that title is already there and its in node with node id "nid"
     }
    

    And if there are no results returned then you may assume you’re good to go.

    Or alternatively you could edit the node table to make the title field UNIQUE and handle the error thrown by MySQL. Don’t really know how feasible that is though.

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

Sidebar

Related Questions

Suppose you have a module that you know is safe. You want to mark
I have this module pattern that stores a bunch of vars. I want to
I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
I have a module that is being used to create only a few page
I have a module that reads the StandardError of a process. Everything works fine,
Let's say that I have a module that has a Queue in it. For
I have a war module that is being built and is including a few
I have an HTTP Module that I use to clean up the JSON returned
I have a python module that imports a module generated with swig. When I
I have a python module that I've been using over the years to process

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.