Database schema documentation? (General)

by JP, Sunday, March 28, 2010, 14:32 (5164 days ago)

We would like to convert our current BB for melanoma patients to MLF but need to save the posts. We would like to write a program that would extract records from the old database and enter them into the MLF database but I see no documentation on the MLF database schema. Can anyone point me in the write direction?

Thanks,
JP

Database schema documentation?

by JP, Sunday, March 28, 2010, 16:42 (5163 days ago) @ JP

I found the sql script that creates the database. Here are my specific questions

In table 'mlf2_entries' I assume:

pid = parent id, the id of the parent post with 0 indicating this post is the top of the thread. Correct?

tid = thread id? How is this generated since it doesn't auto increment?

uniqid = ?? This is a varchar string. What does it mean? How is it generated?

hp =?? What is this entry for?

Also, can someone point me to the php file that actually processes a post and enters it into the the db?

Thanks!

JP

Avatar

Database schema documentation?

by Micha ⌂, Sunday, March 28, 2010, 17:19 (5163 days ago) @ JP

Hi JP,

pid = parent id, the id of the parent post with 0 indicating this post is the top of the thread. Correct?

Yes.

tid = thread id? How is this generated since it doesn't auto increment?

This is the id of the first posting in a thread where pid == 0

uniqid = ?? This is a varchar string. What does it mean? How is it generated?

I don't know.

hp =?? What is this entry for?

Homepage - shown, if the user is not registered.

Also, can someone point me to the php file that actually processes a post and enters it into the the db?

functions.inc.php, isn't it?

regards Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Database schema documentation?

by JP, Sunday, March 28, 2010, 19:32 (5163 days ago) @ Micha

Hi Micha,
Thanks for your reply. One more question:

Hi JP,

tid = thread id? How is this generated since it doesn't auto increment?

This is the id of the first posting in a thread where pid == 0

So all posts in a thread share the same tid?

uniqid = ?? This is a varchar string. What does it mean? How is it generated?

I don't know.

hp =?? What is this entry for?

Homepage - shown, if the user is not registered.

Also, can someone point me to the php file that actually processes a post and enters it into the the db?

functions.inc.php, isn't it?

I could find the INSERT there. I think it's in includes/posting.inc.php but I'm not quite following the logic yet.
Regards,
JP

Avatar

Database schema documentation?

by Alex ⌂, Sunday, March 28, 2010, 19:38 (5163 days ago) @ JP

Hi!

uniqid = ?? This is a varchar string. What does it mean? How is it generated?

It's a unique identifier to avoid double submits generated with uniqid(). You can leave it empty for imported postings.

Also, can someone point me to the php file that actually processes a post and enters it into the the db?

includes/posting.inc.php

Alex

Database schema documentation?

by Fez, Saturday, August 13, 2011, 17:12 (4660 days ago) @ Alex

I want to make page which inserts a new post (in a new thread) by its parameters, such as

testinsert.php?title=XXX&body=YYY&user=123&key=ZZZ

(it's for a robot that posts breaking news)

The way to go would then be:
* find the largest ID
* insert new post with
** inserted ID = largest ID+1
** PID = 0
** TID = inserted ID
** UNIQID = either empty or some random string
** rest are self explanatory
(&key=ZZZ is just a password so no one else can abuse this. nothing to do with the DB)

Should I insert this in mlf2_entries only, or also in mlf2_entries_cache?

Are there other concerns I should take into consideration?

I guess that it's possible that during the split second between I find the largest ID and I post this as largest ID+1, another post could have been made. But that's just so darn unlikely that it's not worth worrying about ... ;-)

Database schema documentation?

by Fez, Sunday, August 14, 2011, 00:23 (4660 days ago) @ Fez

If anyone's interested, here's my code. I've tested it briefly and it works perfectly so far. Hope it's bug free, but would appreciate any feedback if it is not ;-)

** I made a php file. Fill in the parameters as shown
newposting.php?key=1234567890&uid=2&sub=TestXYZ&cat=3&txt=TESTxyz

** Here's the code

<?php
 
//Only allow if correct key
if ($_GET["key"] != "1234567890")
{
echo "Wrong key!";
exit;
}
 
//Parameters
$user_id = $_GET["uid"];
$subject  = $_GET["sub"];
$category = $_GET["cat"];
$text     = $_GET["txt"];
$uniqid = genRandomString(); //Is this necessary
 
 
//Insert in DB
include('config/db_settings.php');
$link = mysql_connect($db_settings['host'], $db_settings['user'], $db_settings['password']);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$result = mysql_query("SELECT id FROM MyDB.mlf2_entries ORDER BY id DESC LIMIT 0,1");
$largestID = mysql_result($result, 0);
$id  = $largestID + 1;
$pid = 0;
$tid = $id;
mysql_query("INSERT INTO MyDB.mlf2_entries (id, pid, tid, uniqid, user_id, subject, category, text) VALUES ($id, '$pid', '$tid', '$uniqid', '$user_id', '$subject', '$category', '$text')");
$result = mysql_query("SELECT time FROM MyDB.mlf2_entries WHERE id = $id");
$last_reply = mysql_result($result, 0);
mysql_query("UPDATE MyDB.mlf2_entries SET last_reply ='$last_reply' WHERE id = $id");
mysql_close($link);
echo "Inserted successfully";
 
 
function genRandomString() {
    $length = 13;
    $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
    $string = '';    
 
    for ($p = 0; $p < $length; $p++) {
        $string .= $characters[mt_rand(0, strlen($characters))];
    }
 
    return $string;
}
 
?>

RSS Feed of thread