<?php

class devtools
{
    public static function switchinstitutionid($a, $b)
    {

        $data = [
            ["table" => "employments", "column" => "institution"],
            ["table" => "institutions", "column" => "id"],
            ["table" => "institutions", "column" => "parent"],
            ["table" => "notices", "column" => "publisher"],
            ["table" => "publications", "column" => "publisher"],
        ];

        foreach ($data as $value) {

            $switch1 = datatable::query("UPDATE " . $value['table'] . " set " . $value['column'] . " = :new WHERE " . $value['column'] . " = :old", ["old" => $a, "new" => 99999]);
            if (!$switch1['success']) {
                display($switch1);
            } else {
                echo $switch1['count'] . " rows updated successfully in " . $value['table'] . " table<br>";
            }

            $switch2 = datatable::query("UPDATE " . $value['table'] . " set " . $value['column'] . " = :new WHERE " . $value['column'] . " = :old", ["old" => $b, "new" => $a]);
            if (!$switch2['success']) {
                display($switch2);
            } else {
                echo $switch2['count'] . " rows updated successfully in " . $value['table'] . " table<br>";
            }

            $switch3 = datatable::query("UPDATE " . $value['table'] . " set " . $value['column'] . " = :new WHERE " . $value['column'] . " = :old", ["old" => 99999, "new" => $b]);
            if (!$switch3['success']) {
                display($switch1);
            } else {
                echo $switch3['count'] . " rows updated successfully in " . $value['table'] . " table<br>";
            }
        }
    }
}
