<?php

$comments = $db->run("SELECT * FROM comment");

$i = 1;
foreach ( $comments as $comment ) {
    echo "$i. Starting...<br>";
    $projectId = $db->cell("SELECT id FROM project WHERE sheetId = ?", $comment['sheetId']);
    echo "$i. projectId: $projectId<br>";
    $db->update('comment', ['projectId' => $projectId], ['id' => $comment['id']]);
    echo "$i. update comment set projectId=$projectId where id=".$comment['id']."<br><br>";

    $i++;
}