1
jlacivita
SQL: get comments from a news storyid
  • 2004/11/8 20:04

  • jlacivita

  • Just popping in

  • Posts: 2

  • Since: 2004/11/8


Hi,

I'm trying to write a migration script to move all of my movable type entries along with their comments and categories over to xoops, using the news module for my entries.

If there's a better way than writing this myself, go ahead and suggest it!

I'm currently stuck figuring out how to related a storyid from the xoops_stories table to the appropriate row in the xoopscomments table.

i can't tell which or what combination of these keys will be useful:

com_id
com_pid
com_rootid
com_modid
com_itemid

thanks!

2
Mithrandir
Re: SQL: get comments from a news storyid

com_id ID of the comment (auto_increment)
com_pid ID of the comment's parent (threaded/nested view)
com_rootid = ID of the comment at the root (threaded/nested view)
com_modid = ID of the (news) module
com_itemid = ID of the (news) item (i.e. storyid)

3
jlacivita
Re:SQL: get comments from a news storyid
  • 2004/11/8 21:06

  • jlacivita

  • Just popping in

  • Posts: 2

  • Since: 2004/11/8


Thanks!

Now i'm having this weird problem... Inserting the story works fine, and inserting a comment onto it also works fine. however, if i reply to the comment (using the website now, not SQL) the reply doesn't show up in nested mode (it does show up in flat mode, though)

what am i doing wrong on the initial comment, that causes this problem down the line?

thanks again!

here is my PHP page that creates a test entry and comment:

$title = "jeremy is really testing!";
$dbuser="xxx";
$dbpass="xxx";
$dbname="xxx"; //the name of the database
$chandle = mysql_connect("xxx", $dbuser, $dbpass)
or die("Connection Failure to Database");
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found. " . $dbuser);

$table="xoops_stories"; //The name of the table
$query1= "INSERT INTO " . $table . " (uid, title, created, published, expired, hometext, bodytext, counter, topicid) VALUES (1, '".$title."', ". time() . ", " . time() . ", 0, 'foo! again, this is the content la la la la la', 'again, more content...', 0, 1)";

$result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1); //do the query

$storyid = mysql_insert_id($chandle);

$row=mysql_fetch_row($result);

if ($result) {
echo "Inserted '$storyid'
";
}
else
{
echo "Maybe not inserted
";
}


$modId = 3;
$query2 = "INSERT INTO xoops_xoopscomments (com_modid, com_itemid, com_created, com_uid, com_ip, com_title, com_text, com_status) VALUES(".$modId.", " . $storyid . ", " . time() . ", 0, '127.0.0.1', '" . $title ." comment', 'phpbar comment text', 2)" ;
$result = mysql_db_query($dbname, $query2) or die("Failed Query of " . $query2); //do the query
$id = mysql_insert_id($this->chandle);

$query3 = "UPDATE xoops_stories SET comments=1 WHERE storyid = " . $storyid;
$result = mysql_db_query($dbname, $query3) or die("Failed Query of " . $query3); //do the query

Login

Who's Online

343 user(s) are online (265 user(s) are browsing Support Forums)


Members: 0


Guests: 343


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits