Пример #1
0
    }
} catch (Exception $e) {
    $mUpdateHelper->printStepMsg($e->getMessage(), true);
}
$mUpdateHelper->exitOnError();
$mUpdateHelper->printStartNextStepMsg('Insert issues');
try {
    foreach ($issues as $k => $issue) {
        $values = array(ISSUE_KEY => $k, ISSUE_DATETIME => $issue['datetime'], ISSUE_CAUSE => $issue['cause'], ISSUE_STATE => $issue['state']);
        // check cause length (<255)
        if (strlen($values[ISSUE_CAUSE]) > 254) {
            $values[ISSUE_CAUSE] = substr($values[ISSUE_CAUSE], 0, 250) . '...';
        }
        // insert new issue
        $mUpdateHelper->printStartSubStepMsg('Insert issue ' . $k);
        $issueId = DBHelper::insertIssue($values);
        // update reports
        if ($issueId > 0) {
            $mUpdateHelper->printEndSubStepMsg(true);
            $mUpdateHelper->printStartSubStepMsg('Update reports in (' . implode(', ', $issue['reports']) . ') with issue id ' . $issueId);
            if (DBHelper::updateReportsIssue($issue['reports'], $issueId)) {
                $mUpdateHelper->printEndSubStepMsg(true);
            } else {
                $mUpdateHelper->printEndSubStepMsg(false);
            }
        } else {
            $mUpdateHelper->printEndSubStepMsg(false, DBHelper::getLastError());
        }
    }
} catch (Exception $e) {
    $mUpdateHelper->printStepMsg($e->getMessage(), true);