query("SELECT * FROM " . TABLE_PREFIX . "comment ORDER BY bugid, dateline ASC"); foreach ($comments as $comment) { if (!isset($replace["$comment[bugid]"])) { $replace["$comment[bugid]"] = array( 'initialreport' => $comment['commentid'], 'dateline' => $comment['dateline'], 'lastposttime' => $comment['dateline'], 'lastpostby' => $comment['userid'] ); } if (!$comment['hidden'] AND !isset($replace["$comment[bugid]"]['hiddenlastposttime'])) { $replace["$comment[bugid]"]['hiddenlastposttime'] = $comment['dateline']; $replace["$comment[bugid]"]['hiddenlastpostby'] = $comment['userid']; } $replace["$comment[bugid]"]['lastposttime'] = $comment['dateline']; } foreach ($replace AS $bugid => $newfields) { $db->query(" UPDATE " . TABLE_PREFIX . "bug SET initialreport = $newfields[initialreport], dateline = $newfields[dateline], lastposttime = $newfields[lastposttime], lastpostby = $newfields[lastpostby], hiddenlastposttime = $newfields[hiddenlastposttime], hiddenlastpostby = $newfields[hiddenlastpostby] WHERE bugid = $bugid" ); echo "

Updated $bugid

"; } ?>