From 41c32ad119ee2619875f3c467e4ac97dcdbfe4fc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 24 Dec 2004 11:56:02 +0000 Subject: [PATCH] r27: Added extra fields to the database so that we don't have to put so much strain on the database when creating a bug list. New tool was created to populate already existing bugs with the new field information. --- docs/update_bug_table_cache.php | 23 +++++++++++++++++++++++ newcomment.php | 6 +++++- newreport.php | 11 ++++++++--- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 docs/update_bug_table_cache.php diff --git a/docs/update_bug_table_cache.php b/docs/update_bug_table_cache.php new file mode 100644 index 0000000..2681a49 --- /dev/null +++ b/docs/update_bug_table_cache.php @@ -0,0 +1,23 @@ +query("SELECT * FROM comment ORDER BY bugid, dateline ASC"); + +while ($comment = $DB_sql->fetch_array($comments)) +{ + if (!isset($replace["$comment[bugid]"])) + { + $replace["$comment[bugid]"] = array('initialreport' => $comment['commentid'], 'dateline' => $comment['dateline'], 'lastposttime' => $comment['dateline'], 'lastpostby' => $comment['userid']); + } + $replace["$comment[bugid]"]['lastposttime'] = $comment['dateline']; +} + +foreach ($replace AS $bugid => $newfields) +{ + $DB_sql->query("UPDATE bug SET initialreport = $newfields[initialreport], dateline = $newfields[dateline], lastposttime = $newfields[lastposttime], lastpostby = $newfields[lastpostby] WHERE bugid = $bugid"); + echo "

Updated $bugid

"; +} + +?> \ No newline at end of file diff --git a/newcomment.php b/newcomment.php index b9152e8..f368e83 100644 --- a/newcomment.php +++ b/newcomment.php @@ -38,16 +38,20 @@ if ($_POST['do'] == 'insert') $vars['comment_parsed'] = htmlspecialcharslike($vars['comment_parsed']); } + $time = time(); + $DB_sql->query(" INSERT INTO " . TABLE_PREFIX . "comment (bugid, userid, dateline, comment, comment_parsed) VALUES ($vars[bugid], " . $bugsys->userinfo['userid'] . ", - " . time() . ", '" . addslasheslike($vars['comment']) . "', + $time, '" . addslasheslike($vars['comment']) . "', '" . addslasheslike(nl2br($vars['comment_parsed'])) . "' )" ); + $DB_sql->query("UPDATE " . TABLE_PREFIX . "bug SET lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $vars[bugid]"); + echo 'comment inserted'; } diff --git a/newreport.php b/newreport.php index 7aefc9f..4f30d54 100755 --- a/newreport.php +++ b/newreport.php @@ -154,18 +154,23 @@ if ($_POST['do'] == 'insert') $bugid = $DB_sql->insert_id(); + $time = time(); + // insert the comment to the database $DB_sql->query(" INSERT INTO " . TABLE_PREFIX . "comment - (bugid, userid, dateline, comment, comment_parsed - ) + (bugid, userid, dateline, comment, comment_parsed) VALUES ($bugid, " . $bugsys->userinfo['userid'] . ", - " . time() . ", '" . addslasheslike($vars['comment']) . "', + $time, '" . addslasheslike($vars['comment']) . "', '" . addslasheslike(nl2br($vars['comment_parsed'])) . "' )" ); + $initialreport = $DB_sql->insert_id(); + + $DB_sql->query("UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bugid"); + echo 'bug is done!'; } -- 2.43.5