コード例 #1
0
<?php

$generalSubjectID = $_POST['generalSubjectID'];
if ($generalSubjectID != '') {
    $generalSubject = new GeneralSubject(new NamedArguments(array('primaryKey' => $generalSubjectID)));
} else {
    $generalSubject = new GeneralSubject();
}
// Update the General Subject if needed
$generalSubject->shortName = str_replace("'", "''", $_POST['shortName']);
try {
    $generalSubject->save();
    $generalSubjectID = $generalSubject->primaryKey;
    $detailSubjectArray = array();
    $detailSubjectArray = explode(':::', $_POST['detailSubjectsList']);
    $detailSubjectIDs = "(-1";
    // Update the GeneralDetailSubject Links
    foreach ($detailSubjectArray as $key => $value) {
        if ($value) {
            $generalDetailSubjectLink = new GeneralDetailSubjectLink();
            $generalDetailSubjectLink->detailedSubjectID = $value;
            $generalDetailSubjectLink->generalSubjectID = $generalSubjectID;
            // Add any Detail Subject Links that are new
            if ($generalDetailSubjectLink->duplicateCheck() == 0) {
                // Add the new link
                try {
                    $generalDetailSubjectLink->save();
                } catch (Exception $e) {
                    echo $e->getMessage();
                }
            }
コード例 #2
0
ファイル: import.php プロジェクト: pontifechs/resources
         continue;
     }
     if ($subject['delimiter'] !== "") {
         $subjectArray = array_map('trim', explode($subject['delimiter'], $data[intval($subject['column']) - 1]));
     } else {
         $subjectArray = array(trim($data[intval($subject['column']) - 1]));
     }
     foreach ($subjectArray as $currentSubject) {
         $index = searchForShortName($currentSubject, $generalSubjectArray);
         if ($index !== null) {
             $generalSubjectID = $generalSubjectArray[$index]['generalSubjectID'];
         } else {
             if ($index === null && $currentSubject != '') {
                 $generalSubjectObj = new GeneralSubject();
                 $generalSubjectObj->shortName = $currentSubject;
                 $generalSubjectObj->save();
                 $generalSubjectID = $generalSubjectObj->primaryKey;
                 $generalSubjectArray = $generalSubjectObj->allAsArray();
                 $generalSubjectInserted++;
             }
         }
         if ($generalSubjectID !== null) {
             $generalDetailSubjectLinkObj = new GeneralDetailSubjectLink();
             $generalDetailID = $generalDetailSubjectLinkObj->getGeneralDetailID($generalSubjectID, -1);
             if ($generalDetailID !== -1) {
                 array_push($generalDetailSubjectLinkIDArray, $generalDetailID);
             }
         }
     }
 }
 // Let's insert data