function deleteAtom($atom, $conceptName) { Notifications::addLog("deleteAtom({$atom}, {$conceptName})", 'DATABASE'); try { $concept = new Concept($conceptName); // This function is under control of transaction check! if (!isset($this->transaction)) { $this->startTransaction(); } $atom = $this->typeConversion($atom, $concept->name); global $tableColumnInfo; $atomEsc = $this->escape($atom); foreach ($tableColumnInfo as $table => $tableInfo) { foreach ($tableInfo as $column => $fieldInfo) { // TODO: could be optimized by doing one query per table. But deleting per column yields the same result (unlike adding) if ($fieldInfo['concept'] == $concept->name || $concept->hasGeneralization($fieldInfo['concept'])) { // If the field can be null, we set all occurrences to null if ($fieldInfo['null']) { $this->Exe("UPDATE `{$table}` SET `{$column}` = NULL WHERE `{$column}` = '{$atomEsc}'"); } else { $this->Exe("DELETE FROM `{$table}` WHERE `{$column}` = '{$atomEsc}'"); } } } } $this->addAffectedConcept($concept->name); // add concept to affected concepts. Needed for conjunct evaluation. Notifications::addLog("Atom {$atom} (and all related links) deleted in database", 'DATABASE'); Hooks::callHooks('postDatabaseDeleteAtom', get_defined_vars()); } catch (Exception $e) { // Catch exception and continue script Notifications::addError($e->getMessage()); } }