Execute record deletion, even when localised records in non-current locale exist.
@return ElementBase
778885
public function deleteLocalisedRecords()
    {
        if ($this->hasExtension(self::FLUENT_CLASS))
        {
            $localisedTables = $this->getLocalisedTables();
            $tableClasses = ClassInfo::ancestry($this->owner, true);

            foreach ($tableClasses as $class)
            {
                $table = DataObject::getSchema()->tableName($class);

                $rootTable = $this->getLocalisedTable($table);
                $rootDelete = SQLDelete::create("\"{$rootTable}\"")
                    ->addWhere(["\"{$rootTable}\".\"ID\"" => $this->ID]);

                // If table isn't localised, simple delete
                if (!isset($localisedTables[$table]))
                {
                    $baseTable = $this->getLocalisedTable($this->baseTable());

                    // The base table isn't localised? Delete the record then.
                    if ($baseTable === $rootTable)
                    {
                        $rootDelete->execute();
                        continue;
                    }

                    $rootDelete
                        ->setDelete("\"{$rootTable}\"")
                        ->addLeftJoin(
                            $baseTable,
                            "\"{$rootTable}\".\"ID\" = \"{$baseTable}\".\"ID\""
                        )
                        // Only when join matches no localisations is it safe to delete
                        ->addWhere("\"{$baseTable}\".\"ID\" IS NULL")
                        ->execute();

                    continue;
                }

                $localisedTable = $this->getLocalisedTable($table);
                $localisedDelete = SQLDelete::create(
                    "\"{$localisedTable}\"",
                    [
                        '"RecordID"' => $this->ID,
                    ]
                );
                $localisedDelete->execute();
            }
        }

        return $this;
    }
487774
public function execute() {
        global $CFG, $DB;

        if (!empty($CFG->gradehistorylifetime)) {
            $now = time();
            $histlifetime = $now - ($CFG->gradehistorylifetime * DAYSECS);
            $tables = [
                'grade_outcomes_history',
                'grade_categories_history',
                'grade_items_history',
                'grade_grades_history',
                'scale_history'
            ];
            foreach ($tables as $table) {
                if ($DB->delete_records_select($table, "timemodified < ?", [$histlifetime])) {
                    mtrace("    Deleted old grade history records from '$table'");
                }
            }
        }
    }
741690
public function onBeforeWrite()
    {
        /** @var string $currentLocale */
        $currentLocale = FluentState::singleton()->getLocale();
        if (!$currentLocale) {
            return;
        }

        // If the record is not versioned, force change
        if (!$this->owner->hasExtension(FluentVersionedExtension::class)) {
            $this->owner->forceChange();
            return;
        }

        // Force a change if the record doesn't already exist in the current locale
        if (!$this->owner->existsInLocale($currentLocale)) {
            $this->owner->forceChange();
        }
    }
539257
protected function runSoftDelete()
    {
        $query = $this->newQuery()->where($this->getKeyName(), $this->getKey());

        $this->setAttribute($column = $this->getDeletedAtColumn(), $time = $this->freshTimestamp());

        $query->update(array($column => $this->fromDateTime($time)));
    }
1011757
public function delete()
    {
        if (!$this->isLoaded()) {
            //Nothing to do, do we need an exception here?
            return;
        }

        $this->dispatch('delete', new DocumentEvent($this));

        //Performing deletion
        $this->odm->collection(static::class)->deleteOne(['_id' => $this->primaryKey()]);
        $this->setField('_id', null, false);
        //Done with deletion

        $this->dispatch('deleted', new DocumentEvent($this));
    }
1049023
public void actionDeleteElementLocale() throws JspException {

        try {
            Locale loc = getElementLocale();
            m_content.removeLocale(loc);
            //write the modified xml content
            writeContent();
            List<Locale> locales = m_content.getLocales();
            if (locales.size() > 0) {
                // set first locale as new display locale
                Locale newLoc = locales.get(0);
                setParamElementlanguage(newLoc.toString());
                m_elementLocale = newLoc;
            } else {
                if (LOG.isErrorEnabled()) {
                    LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, getParamResource()));
                }
            }

        } catch (CmsXmlException e) {
            // an error occurred while trying to delete the locale, stop action
            showErrorPage(e);
        } catch (CmsException e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage(), e);
            }
        }
    }
204037
public function destruct()
    {
        $this->_id = [];
        $this->_source_db = null;
        $this->_record = [];
        $this->_changed = [];
        return $this;
    }
516073
final public function delete() {
        global $DB;

        if ($this->raw_get('id') <= 0) {
            throw new coding_exception('id is required to delete');
        }

        // Hook before delete.
        $this->before_delete();

        $result = $DB->delete_records(static::TABLE, array('id' => $this->raw_get('id')));

        // Hook after delete.
        $this->after_delete($result);

        // Reset the ID to avoid any confusion, this also invalidates the model's data.
        if ($result) {
            $this->raw_set('id', 0);
        }

        return $result;
    }
672349
function removeThis()
    {
        $db = eZDB::instance();
        $db->begin();

        // Set all elements using this status to 0 (undefined).
        $statusID = (int)$this->StatusID;
        $db->query( "UPDATE ezorder SET status_id = 0 WHERE status_id = $statusID" );
        $db->query( "UPDATE ezorder_status_history SET status_id = 0 WHERE status_id = $statusID" );

        $id = $this->ID;
        eZPersistentObject::removeObject( eZOrderStatus::definition(), array( "id" => $id ) );

        $db->commit();

        eZOrderStatus::flush();
    }
705595
public function execute()
    {

        $this->query("DELETE FROM `{{NAILS_DB_PREFIX}}app_setting` WHERE `grouping` = 'email' and `key` != 'from_name' and `key` != 'from_email';");
        /**
         * Convert admin changelog data into JSON strings rather than use serialize
         */

        $oResult = $this->query('SELECT id, email_vars FROM {{NAILS_DB_PREFIX}}email_archive');
        while ($oRow = $oResult->fetch(\PDO::FETCH_OBJ)) {

            $mOldValue = unserialize($oRow->email_vars);
            $sNewValue = json_encode($mOldValue);

            //  Update the record
            $sQuery = '
                UPDATE `{{NAILS_DB_PREFIX}}email_archive`
                SET
                    `email_vars` = :newValue
                WHERE
                    `id` = :id
            ';

            $oSth = $this->prepare($sQuery);

            $oSth->bindParam(':newValue', $sNewValue, \PDO::PARAM_STR);
            $oSth->bindParam(':id', $oRow->id, \PDO::PARAM_INT);

            $oSth->execute();
        }
    }
105313
public function execute() {
        global $DB;

        $timenow = time();

        // Delete old backup_controllers and logs.
        $loglifetime = get_config('backup', 'loglifetime');
        if (!empty($loglifetime)) {  // Value in days.
            $loglifetime = $timenow - ($loglifetime * 3600 * 24);
            // Delete child records from backup_logs.
            $DB->execute("DELETE FROM {backup_logs}
                           WHERE EXISTS (
                               SELECT 'x'
                                 FROM {backup_controllers} bc
                                WHERE bc.backupid = {backup_logs}.backupid
                                  AND bc.timecreated < ?)", array($loglifetime));
            // Delete records from backup_controllers.
            $DB->execute("DELETE FROM {backup_controllers}
                          WHERE timecreated < ?", array($loglifetime));
        }

    }
1158148
public function execute() {
        global $DB;

        // Automatic creation of deletion requests must be enabled.
        if (get_config('tool_dataprivacy', 'automaticdeletionrequests')) {
            // Select all deleted users that do not have any delete data requests created for them.
            $sql = "SELECT DISTINCT(u.id)
                  FROM {user} u
             LEFT JOIN {tool_dataprivacy_request} r
                       ON u.id = r.userid
                 WHERE u.deleted = ?
                       AND (r.id IS NULL
                           OR r.type != ?)";

            $params = [
                1,
                api::DATAREQUEST_TYPE_DELETE
            ];

            $deletedusers = $DB->get_records_sql($sql, $params);
            $createdrequests = 0;

            foreach ($deletedusers as $user) {
                api::create_data_request($user->id, api::DATAREQUEST_TYPE_DELETE,
                    get_string('datarequestcreatedfromscheduledtask', 'tool_dataprivacy'),
                    data_request::DATAREQUEST_CREATION_AUTO);
                $createdrequests++;
            }

            if ($createdrequests > 0) {
                mtrace($createdrequests . ' delete data request(s) created for existing deleted users');
            }
        }
    }
913835
public function run()
    {
        $this->_scanner = new Scanner();
        $this->_scanner->run();
        $this->_scanner->stdout('Deleted language elements - BEGIN', Console::FG_RED);

        $languageSourceIds = $this->_scanner->getRemovableLanguageSourceIds();

        $this->_initLanguageElements($languageSourceIds);

        LanguageSource::deleteAll(['id' => $languageSourceIds]);

        $this->_scanner->stdout('Deleted language elements - END', Console::FG_RED);

        return count($languageSourceIds);
    }
419136
public function pop() {
        $e = array_pop($this->elements);
        $this->fire(new ListDeleteEvent($e, $this->count()));
        return $e;
    }
489303
public function requireDefaultRecords()
    {
        if (!$this->supportsElemental()) {
            return;
        }

        $ownerClass = get_class($this->owner);
        $elementalAreas = $this->owner->getElementalRelations();
        $schema = $this->owner->getSchema();

        // There is no inbuilt filter for null values
        $where = [];
        foreach ($elementalAreas as $areaName) {
            $queryDetails = $schema->sqlColumnForField($ownerClass, $areaName . 'ID');
            $where[] = $queryDetails . ' IS NULL OR ' . $queryDetails . ' = 0' ;
        }

        foreach ($ownerClass::get()->where(implode(' OR ', $where)) as $elementalObject) {
            $elementalObject->ensureElementalAreasExist($elementalAreas)->write();
        }
    }
637547
def remove(self, record):
        """"""
        self._field.validate_value(record)
        del self._elements[record.id]
        self._sync_field()
414463
public function delete()
    {
        $app = Facade::getFacadeApplication();
        $db = $app->make('database')->connection();

        $cvID = $this->cvID;
        $c = Page::getByID($this->cID, $cvID);
        $cID = $c->getCollectionID();

        $q = "select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?";
        $r = $db->executeQuery($q, array(
            $cID,
            $cvID,
        ));
        while ($row = $r->fetch()) {
            if ($row['bID']) {
                $b = Block::getByID($row['bID'], $c, $row['arHandle']);
                if (is_object($b)) {
                    $b->deleteBlock();
                }
                unset($b);
            }
        }

        $features = CollectionVersionFeatureAssignment::getList($this);
        foreach ($features as $fa) {
            $fa->delete();
        }

        $category = $app->make('Concrete\Core\Attribute\Category\PageCategory');
        $attributes = $category->getAttributeValues($this);
        foreach ($attributes as $attribute) {
            $category->deleteValue($attribute);
        }

        $db->executeQuery('delete from CollectionVersionBlockStyles where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));
        $db->executeQuery('delete from CollectionVersionThemeCustomStyles where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));
        $db->executeQuery('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));
        $db->executeQuery('delete from CollectionVersionAreaStyles where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));

        $db->executeQuery('delete from PageTypeComposerOutputBlocks where cID = ? and cvID = ?', array(
            $cID,
            $cvID,
        ));

        $q = "delete from CollectionVersions where cID = '{$cID}' and cvID='{$cvID}'";
        $db->executeQuery($q);
        $this->refreshCache();
    }