コード例 #1
0
ファイル: list.php プロジェクト: nyairo/mcl-search
}
echo '</table>';
// open db connection
$cxn = mysql_connect($mcl_db_host, $mcl_db_uid, $mcl_db_pwd);
if (!$cxn) {
    die('Could not connect to database: ' . mysql_error());
}
mysql_select_db($mcl_enhanced_db_name);
// New list
if ($_POST['action'] == 'new') {
    // Create the new list definition
    $cld = new ConceptListDefinition();
    $cld->setName($list_name);
    $cld->setDescription($list_description);
    // create the new list
    $cl = new ConceptList($cld);
    foreach ($arr_concepts as $c) {
        $cl->addConcept($c->concept_id);
        // TODO: $cl->addConcept($c->dict_id, $c->concept_id);
    }
    // Commit to database
    $clf = new ConceptListFactory();
    $clf->setConnection($cxn);
    if (!$clf->insertConceptList($cl)) {
        trigger_error('Could not create list', E_USER_ERROR);
    } else {
        echo 'successfully created list!';
    }
} elseif ($action == 'add') {
    //
} elseif ($action == 'remove') {
コード例 #2
0
 /**
  * Create a new concept list with the passed name and source concept 
  * dictionary. Return the new concept_list_id on success, or false on failure.
  */
 public function insertConceptList(ConceptList $cl)
 {
     // Make sure the concept list name is unique
     if (!$this->isUniqueConceptListName($cl->cld->getName())) {
         trigger_error('Unable to create list, because concept list name is not unique: <strong>' . $list_name . '</strong>', E_USER_ERROR);
     }
     // Insert the list
     $sql_insert_list = 'insert into mcl.concept_list (list_name) values (' . "'" . mysql_real_escape_string($cl->cld->getName(), $this->getConnection()) . "')";
     if (!mysql_query($sql_insert_list, $this->getConnection()) || !($new_concept_list_id = mysql_insert_id($this->getConnection()))) {
         trigger_error('Unable to insert record into mcl.concept_list: ' . mysql_error());
         return false;
     }
     // Insert the concepts
     if ($cl->getCount() && $new_concept_list_id) {
         // Build the sql statement
         $arr_concepts = $cl->getArray();
         $glue = '),(' . $new_concept_list_id . ',';
         $sql_insert_concepts = 'insert into mcl.concept_list_map (concept_list_id, concept_id) values ' . '(' . $new_concept_list_id . ',' . implode($glue, $arr_concepts) . ')';
         if ($this->debug) {
             echo '<p>Inserting concept ids into list ' . $new_concept_list_id . ':<br />' . $sql_insert_concepts . '</p>';
         }
         if (!mysql_query($sql_insert_concepts, $this->getConnection())) {
             trigger_error('Unable to insert concepts into list ' . $new_concept_list_id . ': ' . mysql_error());
         }
     }
     return $new_concept_list_id;
 }