updated update script and merged lobbylens admin scripts
[contractdashboard.git] / admin / linkAmendments.php
blob:a/admin/linkAmendments.php -> blob:b/admin/linkAmendments.php
<?php <?php
include_once ("../lib/common.inc.php"); include_once ("../lib/common.inc.php");
$query = "SELECT CNID,parentCN,amendmentReason FROM `contractnotice` WHERE $query = 'SELECT c."CNID",c."parentCN",c."amendmentReason",p."childCN" FROM contractnotice as c LEFT OUTER JOIN contractnotice as p on c."parentCN" = p."CNID"
parentCN > 0 "; WHERE
$result = mysql_query($query); c."parentCN" > 0 AND p."childCN" IS NULL ';
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $query = $conn->prepare($query);
$result2 = mysql_query("UPDATE contractnotice SET childCN = '" . $query->execute();
$row['CNID'] . "', amendmentReason = '" . if (!$query) {
$row['amendmentReason'] . "' where CNID = '" . databaseError($conn->errorInfo());
$row['parentCN'] . "';"); }
if ($result2) echo $row['CNID'] . " linked to parent " . $row['parentCN'] . foreach ($query->fetchAll() as $row) {
  $conn->exec('UPDATE contractnotice SET "childCN" = \'' .
  $row['CNID'] . '\', "amendmentReason" = \'' .
  $row['amendmentReason'] . '\' where "CNID" = \'' .
  $row['parentCN'] . '\';');
  echo 'UPDATE contractnotice SET "childCN" = \'' .
  $row['CNID'] . '\', "amendmentReason" = \'' .
  $row['amendmentReason'] . '\' where "CNID" = \'' .
  $row['parentCN'] . '\';';
  $errors = $conn->errorInfo();
   
  if ($errors[1] == 7 || $errors[1] ==0)
  echo $row['CNID'] . " linked to parent " . $row['parentCN'] .
"<br>\n"; "<br>\n";
else "error" . mysql_error(); else print_r($errors);
   
} }
  // also need to eliminate CN 100528/100529 - check for double parent CNs with no childCN, latest sequent CN id wins childCN = 0
?> ?>