コード例 #1
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;
 }