r66: Moving all DB stuff to be handled by ISSO. Working with our one big $bugsys...
[bugdar.git] / docs / update_bug_table_cache.php
1 <?php
2
3 chdir('./../');
4 require_once('./global.php');
5
6 $comments = $db->query("SELECT * FROM comment ORDER BY bugid, dateline ASC");
7
8 while ($comment = $db->fetch_array($comments))
9 {
10 if (!isset($replace["$comment[bugid]"]))
11 {
12 $replace["$comment[bugid]"] = array('initialreport' => $comment['commentid'], 'dateline' => $comment['dateline'], 'lastposttime' => $comment['dateline'], 'lastpostby' => $comment['userid']);
13 }
14 $replace["$comment[bugid]"]['lastposttime'] = $comment['dateline'];
15 }
16
17 foreach ($replace AS $bugid => $newfields)
18 {
19 $db->query("UPDATE bug SET initialreport = $newfields[initialreport], dateline = $newfields[dateline], lastposttime = $newfields[lastposttime], lastpostby = $newfields[lastpostby] WHERE bugid = $bugid");
20 echo "<p>Updated $bugid</p>";
21 }
22
23 ?>