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

  • Home
  • SEARCH
  • 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 6113977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:55:15+00:00 2026-05-23T14:55:15+00:00

I’m building a batch importer module that will take data from one database and

  • 0

I’m building a batch importer module that will take data from one database and create the nodes in drupal. The code to create the node object is this:

$node = new stdClass();
$node->type = 'jobs';
$node->uid = 1;
$node->status = $row->J_Approved;
$node->title = $row->J_Title;
$node->comment = 0;
$node->revision = 1;
$node->promote = 0;
$node->sticky = 0;
$node->created = $row->J_DateTime_Mod;
$node->field_description = $row->J_Body;
$node->field_email = $row->J_MI_Email;
$node->field_jobs_fax = $row->J_MI_Phone;
$node->field_aia_firm = $row->J_AIA;
$node->field_name = $row->J_Sub_Name;
$node->field_phone = $row->J_Sub_Phone;
$node->field_jobs_email = $row->J_Sub_Email;
$node = node_submit($node);
node_save($node);

And the above outputs this in my debug window http://screencast.com/t/R5PhWZWraIR8
When I run this, it doesn’t create the node, but as you can see from the screencast, it sets $node->validates to 1, so im assuming it is valid. I’ve spent around 5 hours trying to debug this and still can’t figure it out. Any help would be appreciated…

  • 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-23T14:55:15+00:00Added an answer on May 23, 2026 at 2:55 pm

    Drupal 6 example:

    <?php
    $node = new stdClass(); //Create instance of class stdClass which will create node for you.
    $node->type = 'library'; //Name of the content type
    $node->field_book_no[0][value] = 22;//Book number CCK Field
    $node->field_book_name[0][value] = "Drupal"; //Book name  CCK Field
    $node->field_book_author[0][value]='Sachin'; //Author name -  CCK field
    $node->field_year[0][value]='2011'; //Publication year - CCK field
    $node->uid = 1; // user id, 1 is created by admin
    $node->status = 1;//1 is published, 0 is unpublished
    $node->promote = 0;//1 is promote to home page, 0 is not to promote on home page
    node_save($node); // Save this node
    ?>
    

    node_load() doesn’t return anything, so it doesn’t check.

    You can check it with:

    $new_node = node_load($node->nid, NULL, TRUE);
    

    Where the 3d arg will reset the cache before loading the node. Expensive, but that’s the only way I know.

    You would then have to check the node->[vars] against each other, and return TRUE if they all match.

    I credit http://www.learn-drupal.in/cck/how-to-create-a-drupal-node-programmatically.html with the node_save code example above.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.