Delete a competency framework by id.

Requires moodle/competency:competencymanage capability at the system context.

@param int $id The record to delete. This will delete alot of related data - you better be sure.
@return boolean
766591
public static function delete_framework($id) {
        global $DB;
        static::require_enabled();
        $framework = new competency_framework($id);
        require_capability('moodle/competency:competencymanage', $framework->get_context());

        $events = array();
        $competenciesid = competency::get_ids_by_frameworkid($id);
        $contextid = $framework->get('contextid');
        if (!competency::can_all_be_deleted($competenciesid)) {
            return false;
        }
        $transaction = $DB->start_delegated_transaction();
        try {
            if (!empty($competenciesid)) {
                // Delete competencies.
                competency::delete_by_frameworkid($id);

                // Delete the related competencies.
                related_competency::delete_multiple_relations($competenciesid);

                // Delete the evidences for competencies.
                user_evidence_competency::delete_by_competencyids($competenciesid);
            }

            // Create a competency framework deleted event.
            $event = \core\event\competency_framework_deleted::create_from_framework($framework);
            $result = $framework->delete();

            // Register the deleted events competencies.
            $events = \core\event\competency_deleted::create_multiple_from_competencyids($competenciesid, $contextid);

        } catch (\Exception $e) {
            $transaction->rollback($e);
        }

        // Commit the transaction.
        $transaction->allow_commit();

        // If all operations are successfull then trigger the delete event.
        $event->trigger();

        // Trigger deleted event competencies.
        foreach ($events as $event) {
            $event->trigger();
        }

        return $result;
    }
1202471
public function destroy($id)
    {
        try {
            return (bool) $this->db->from($this->table)
                    ->where($this->columns['id'])->eq($id)
                    ->delete();
        } catch (PDOException $e) {
            return false;
        }
    }
1304160
public static function delete($id)
    {
        $db = new DatabaseManager();
        $connection = $db->getDbh();

        $statement = $connection->prepare('DELETE from ' . static::getTableName()  . ' WHERE id=:id');
        $statement->bindParam(':id', $id, \PDO::PARAM_INT);
        $queryWasSuccessful = $statement->execute();
        return $queryWasSuccessful;
    }
992311
public function destroy($id)
	{
		$tableName = $this->db->parseField($this->tableName);
		$sessionIDField = $this->db->parseField('session_id');
		return $this->db->execute(<<<SQL
delete from {$tableName} where {$sessionIDField} = %s
SQL
,array($id));
	}
539738
public function actionDeleteLanguage($id)
    {
        $model = $this->findLanguageModel($id);
        $model->delete();
        return $this->redirect(['edit', 'id' => $model->context_id]);
    }
8343
public function delete($id)
    {
        if ($id instanceof DocumentInterface) {
            $id = $id->getId();
        }

        $path = $this->getPathForDocument($id);

        return unlink($path);
    }
650810
public function deleteById($id)
    {
        $this->validateTableAndIdentityColumn();
        // If the soft delete is activated
        if ($this->deleteColumnName) {
            $query = <<<EOQ
UPDATE {$this->getTableName()}
SET {$this->deleteColumnName} = 1
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s
EOQ;
        } else {
            $query = <<<EOQ
DELETE FROM {$this->getTableName()}
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s
EOQ;
        }

        $params = array('identity' => $id);

        return (bool)$this->db->query($query, $params);
    }
291111
public function delete(string $id) : bool
    {
        $query = $this->storageTable->find('all', [
            'conditions' => [self::FILE_STORAGE_FOREIGN_KEY => $id]
        ]);
        $entity = $query->first();

        if (is_null($entity)) {
            return false;
        }

        if ($this->storageTable->delete($entity)) {
            $this->removeThumbnails($entity);

            return true;
        }

        return false;
    }
954967
protected static function delete_user_competencies($userid) {
        global $DB;
        $usercontext = context_user::instance($userid);

        // Remove all the comments made on user competencies.
        \core_comment\privacy\provider::delete_comments_for_all_users($usercontext, 'competency', 'user_competency');

        // Find the user competency IDs.
        $ucids = $DB->get_fieldset_select(user_competency::TABLE, 'id', 'userid = :userid', ['userid' => $userid]);
        if (empty($ucids)) {
            return;
        }
        list($insql, $inparams) = $DB->get_in_or_equal($ucids, SQL_PARAMS_NAMED);

        // Delete all the evidence associated with competencies.
        $DB->delete_records_select(evidence::TABLE, "usercompetencyid $insql", $inparams);

        // Delete all the record of competency.
        $DB->delete_records_select(user_competency::TABLE, "id $insql", $inparams);
    }
654604
public function delete($id)
    {
        $db = new DatabaseManager();
        $connection = $db->getDbh();

        $sql = 'DELETE from :table WHERE id=:id';
        $sql = str_replace(':table', $this->tableName, $sql);

        $statement = $connection->prepare($sql);
//        $statement->bindParam(':table',  $this->tableName);
        $statement->bindParam(':id', $id, \PDO::PARAM_INT);

        $queryWasSuccessful = $statement->execute();
        return $queryWasSuccessful;
    }
424514
public static function destroy($id)
    {
        return Symphony::Database()->query(
            sprintf(
                "DELETE
                FROM `tbl_sessions`
                WHERE `session` = '%s'",
                Symphony::Database()->cleanValue($id)
            )
        );
    }
852474
public static function delete_purpose($id) {
        $purpose = new purpose($id);
        if ($purpose->is_used()) {
            throw new \moodle_exception('Purpose with id ' . $id . ' can not be deleted because it is used.');
        }
        return $purpose->delete();
    }
702514
public function delete($id)
	{
		$id = trim($this->escape($id));
		$hits = $this->getIndex()->find("xref_id:\"{$id}\"");
		if (empty($hits)) {
			return false;
		}
		
		foreach ($hits as $hit) {
			$this->getIndex()->delete($hit->id);
		}
		
		return true;
	}
1240315
public function delete(string $id)
    {
        $this->request->allowMethod(['post', 'delete']);
        $dashboard = $this->Dashboards->get($id);

        if ($this->Dashboards->delete($dashboard)) {
            /** @var \Search\Model\Table\WidgetsTable */
            $widgetTable = TableRegistry::get('Search.Widgets');
            $widgetTable->trashAll([
                'dashboard_id' => $id
            ]);

            $this->Flash->success((string)__('The dashboard has been deleted.'));
        } else {
            $this->Flash->error((string)__('The dashboard could not be deleted. Please, try again.'));
        }

        return $this->redirect(['action' => 'index']);
    }
632588
public function delete($id) {
        $params = $this->parseUrl($id);

        try {
            $this->getClient()->deleteObject(array(
                'Bucket' => $params['bucket'],
                'Key' => $params['key']
            ));
        } catch (S3Exception $e) {
            return false;
        }

        return true;
    }
1026635
public static function remove_competency_from_course($courseid, $competencyid) {
        static::require_enabled();
        // Check the user have access to the course.
        self::validate_course($courseid);

        // First we do a permissions check.
        $context = context_course::instance($courseid);

        require_capability('moodle/competency:coursecompetencymanage', $context);

        $record = new stdClass();
        $record->courseid = $courseid;
        $record->competencyid = $competencyid;

        $coursecompetency = new course_competency();
        $exists = course_competency::get_record(array('courseid' => $courseid, 'competencyid' => $competencyid));
        if ($exists) {
            // Delete all course_module_competencies for this competency in this course.
            $cmcs = course_module_competency::get_records_by_competencyid_in_course($competencyid, $courseid);
            foreach ($cmcs as $cmc) {
                $cmc->delete();
            }
            return $exists->delete();
        }
        return false;
    }
558814
public function delete($id = null)
    {
        if (!is_null($id)) {
            $this->setId($id);
        }

        return $this->getDbGateway()->delete($this->getId());
    }