Hello,
I am trying to insert some forum nodes for a job board through mysql/php. I have ran the following 4 queries:
$query1 = "INSERT INTO `node_revisions` ( `nid` , `vid` , `uid` , `title` , `body` , `teaser` , `log` , `timestamp` , `format` )
VALUES ('$id', '$id', '358', '$title', '$html', '$html', '', '$t', '3')";
mysql_query($query1) or DIE("node revision insert failed");
$query2 ="INSERT INTO `node` ( `nid` , `vid` , `type` , `title` , `uid` , `status` , `created` , `changed` , `comment` , `promote` , `moderate` , `sticky` )
VALUES ('$id', '$id', 'forum', '$title', '1', '1', '$t', '$t', '2', '0', '0', '0')";
mysql_query($query2) or DIE("node insert failed");
$query3 ="INSERT INTO `node_access` ( `nid` , `gid` , `realm` , `grant_view` , `grant_update` , `grant_delete` )
VALUES ('$id', '0', 'tac_lite', '1', '0', '0')";
mysql_query($query3) or DIE("node access insert failed");
$query4="INSERT INTO `forum` ( `nid` , `vid` , `tid` )
VALUES ('$id', '$id', '$tid')";
mysql_query($query4) or DIE("forum insert failed");
All goes well, and looks identical (except for NID/VID to a forum node inserted through the gui. However, only the gui version is displayed. Why is this? I can view/edit the node as usual through admin/content or node/($id). I must be missing some kind of hook or database modification?!
Thanks for any help.
Comments
rss feed in forum shows both nodes?!
Both are visible at http://localhost/?q=taxonomy/term/70, but when I click on http://localhost/?q=forum/70, only the second version is shown.
found a solution
as i have posted on http://drupal.org/node/64691,
thanks for everyone who helped steer me in the right direction. In the end, I needed to call node_save,
forum_insert and taxonomy_node_save
**And for newer drupal users like myself, you need to call the module functions from within a drupal node. Otherwise, you need to include a bunch of files
add a field to only have to call node_save()
I was given the advice, that I can replace
node_save($node);
forum_insert($node);
$terms[] = $node->tid;
taxonomy_node_save($node->nid, $terms);
with
$node->taxonomy[] = $node->tid;
node_save($node);
since node_save calls forum_insert and taxonomy_node_save
I've tested this and it works!
fantastic
This is perfect timing, i was just about to start banging my head against the wall when i stumbled onto this.
Cheers for the follow up as well :)
API Reference
API Reference node_save
http://api.drupal.org/api/HEAD/function/node_save
----
Darly