CommonDBTM::deleteFromDB PHP Method

deleteFromDB() public method

Mark deleted or purge an item in the database
public deleteFromDB ( $force ) : true
$force force the purge of the item (not used if the table do not have a deleted field) (default 0)
return true if succeed else false
    function deleteFromDB($force = 0)
    {
        global $DB, $CFG_GLPI;
        if ($force == 1 || !$this->maybeDeleted() || $this->useDeletedToLockIfDynamic() && !$this->isDynamic()) {
            $this->cleanDBonPurge();
            if ($this instanceof CommonDropdown) {
                $this->cleanTranslations();
            }
            $this->cleanHistory();
            $this->cleanRelationData();
            $this->cleanRelationTable();
            $query = "DELETE\n                   FROM `" . $this->getTable() . "`\n                   WHERE `id` = '" . $this->fields['id'] . "'";
            if ($result = $DB->query($query)) {
                $this->post_deleteFromDB();
                return true;
            }
        } else {
            // Auto set date_mod if exsist
            $toadd = '';
            if (isset($this->fields['date_mod'])) {
                $toadd = ", `date_mod` ='" . $_SESSION["glpi_currenttime"] . "' ";
            }
            $query = "UPDATE `" . $this->getTable() . "`\n                   SET `is_deleted`='1' {$toadd}\n                   WHERE `id` = '" . $this->fields['id'] . "'";
            $this->cleanDBonMarkDeleted();
            if ($result = $DB->query($query)) {
                return true;
            }
        }
        return false;
    }
CommonDBTM