Warning: call this function after where clause or all data will be deleted
Deletes all or defined record(s) in the where clause
@return mixed
425848
public function delete(){

        $query= /** @lang text */
            'DELETE FROM '.self::sanitize(static::$table);


        if (!empty($this->whereby)) {

            $query = $query . ' WHERE ' . $this->whereby;
        }

        try {
            $this->exec($query);

            static::$response["status"] = "success";
            static::$response["response"] = 'success';
            static::$response['code'] = 200;
            return static::terminate(static::$response);
        } catch (Exception $e) {
            static::$response["status"] = "error";
            static::$response["response"] = $e->getMessage();
            static::$response['code'] = $e->getCode();
            return static::terminate(static::$response);
        }
    }
179170
protected function getDeleteQuery()
    {
        $foreign = $this->getAttribute($this->foreignKey);

        $query = $this->newQuery()->where($this->foreignKey, $foreign);

        return $query->where($this->otherKey, $this->getAttribute($this->otherKey));
    }
1197930
public function delete()
    {
        // Delete row
        $result = static::connection()
            ->delete()
            ->from(static::table())
            ->where(static::$_primaryKey . " = ?", $this->{static::$_primaryKey})
            ->limit(1)
            ->exec();

        // Run filters
        if ($result) {
            $this->runFilters('after', 'delete');
        }

        return $result;
    }
619852
protected function deleteExtraRecords()
    {
        try {
            $limit = (int)($this->limitMax);
        } catch (\Exception $ex) {
            Yii::error($ex->getMessage(), __METHOD__);
            return 0;
        }
        $host = $this->host;
         /* @var $host \rhosocial\user\User */
        $count = static::find()->createdBy($host)->count();
        Yii::info($host->getReadableGUID() . " has $count login logs.", __METHOD__);
        if ($count > $limit) {
            foreach (static::find()->createdBy($host)->orderByCreatedAt()->limit($count - $limit)->all() as $login) {
                /* @var $login static */
                $result = $login->delete();
                if (YII_ENV_DEV) {
                    Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
                }
            }
        }
        return $count - $limit;
    }
757181
public function where()
	{
		$condition = func_get_args();
		is_array(reset($condition)) and $condition = reset($condition);

		return $this->_where($condition);
	}
189601
public function index_onDelete()
    {
        if (method_exists($this->controller, 'onDelete')) {
            return call_user_func_array([$this->controller, 'onDelete'], func_get_args());
        }

        /*
         * Validate checked identifiers
         */
        $checkedIds = post('checked');

        if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) {
            Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
            return $this->controller->listRefresh();
        }

        /*
         * Establish the list definition
         */
        $definition = post('definition', $this->primaryDefinition);

        if (!isset($this->listDefinitions[$definition])) {
            throw new ApplicationException(Lang::get('backend::lang.list.missing_parent_definition', compact('definition')));
        }

        $listConfig = $this->controller->listGetConfig($definition);

        /*
         * Create the model
         */
        $class = $listConfig->modelClass;
        $model = new $class;
        $model = $this->controller->listExtendModel($model, $definition);

        /*
         * Create the query
         */
        $query = $model->newQuery();
        $this->controller->listExtendQueryBefore($query, $definition);

        $query->whereIn($model->getKeyName(), $checkedIds);
        $this->controller->listExtendQuery($query, $definition);

        /*
         * Delete records
         */
        $records = $query->get();

        if ($records->count()) {
            foreach ($records as $record) {
                $record->delete();
            }

            Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
        }
        else {
            Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
        }

        return $this->controller->listRefresh($definition);
    }
1114387
public function delete ()
	{
		$this->before_delete();

		$statement = 'DELETE FROM ' . static::$table_name;

		$pk = $this->primary_key_condition();

		$statement .= ' WHERE ' . $pk->statement;

		$result = $this->db->query($statement, $pk->values->getArrayCopy(), 'multi', null, false);

		$this->stored = true;
		$this->updated = false;

		$this->after_delete();

		return true;
	}
706090
public function delete()
    {
        $this->brokenOnDelete = true;
        $this->onBeforeDelete();
        if ($this->brokenOnDelete) {
            user_error(static::class . " has a broken onBeforeDelete() function."
                . " Make sure that you call parent::onBeforeDelete().", E_USER_ERROR);
        }

        // Deleting a record without an ID shouldn't do anything
        if (!$this->ID) {
            throw new LogicException("DataObject::delete() called on a DataObject without an ID");
        }

        // TODO: This is quite ugly.  To improve:
        //  - move the details of the delete code in the DataQuery system
        //  - update the code to just delete the base table, and rely on cascading deletes in the DB to do the rest
        //    obviously, that means getting requireTable() to configure cascading deletes ;-)
        $srcQuery = DataList::create(static::class)
            ->filter('ID', $this->ID)
            ->dataQuery()
            ->query();
        $queriedTables = $srcQuery->queriedTables();
        $this->extend('updateDeleteTables', $queriedTables, $srcQuery);
        foreach ($queriedTables as $table) {
            $delete = SQLDelete::create("\"$table\"", array('"ID"' => $this->ID));
            $this->extend('updateDeleteTable', $delete, $table, $queriedTables, $srcQuery);
            $delete->execute();
        }
        // Remove this item out of any caches
        $this->flushCache();

        $this->onAfterDelete();

        $this->OldID = $this->ID;
        $this->ID = 0;
    }
1206426
public function get_by()
    {
        $where = func_get_args();

        if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
        {
            $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
        }

		$this->_set_where($where);

        $this->trigger('before_get');

        $row = $this->_database->get($this->_table)
                        ->{$this->_return_type()}();
        $this->_temporary_return_type = $this->return_type;

        $row = $this->trigger('after_get', $row);

        $this->_with = array();
        return $row;
    }
415107
public function delete()
        {
            $query = array(
                "DELETE FROM",
                $this->_quoteIdentifier($this->_table_name)
            );

            $this->_addIdColumnConditions($query);

            return self::_execute(join(" ", $query), Arrays::is($this->id(true)) ? array_values($this->id(true)) : array($this->id(true)), $this->_connection_name);
        }
981750
public function delete() {

		if (empty(static::$table))
			$table = strtolower(substr(static::class, strpos(static::class, '\\')+1));
		else
			$table = static::$table;

		if ($table != '') {
			if ($this->_id != '' || (is_array($this->_id) && count($this->_id) > 0) ) {
				$before = $this->before();
				if (is_array($before) && count($before) > 1) {
					if (isset($before['delete'])) {
						$delete = $before['delete'];
						while(list($field, $value) = each($delete))
							$this->_id[$field] = $value;
					}
				}
				$ret = self::$db->$table->delete($this->_id);
				$after = $this->after();
				if (is_array($after) && count($after) > 1) {
					if (isset($after['delete']) && is_callable($after['delete'])) {
						$delete = $after['delete'];
						$delete($this->_id);
					}
				}
				$this->_data[$table] = array();
			} else
				$ret = FALSE;
		}

		return $ret;
	}
1105823
public function deleteAll()
    {
        $delete = $this->dsql();
        $delete->owner->beginTransaction();
        $this->hook('beforeDeleteAll', array($delete));
        $delete->delete();
        $this->hook('afterDeleteAll');
        $delete->owner->commit();
        $this->reset();

        return $this;
    }
262883
public function delete()
	{
		$query = $this->getDeleteQuery();

		$query->where($this->morphType, $this->getAttribute($this->morphType));

		return $query->delete();
	}
85740
public function deleteDataWhere( $where = array(), $debug = 1 )
	{
		$conditions	= $this->getConditionQuery( $where );
		if( $conditions )
		{
			$query	= "DELETE FROM ".$this->getTableName()." WHERE ".$conditions;
			$result	= $this->dbc->Execute( $query, $debug );
			$this->defocus();
			return $result;
		}
	}
901345
public function toDeleteSQL()
    {
        $sql = [];
        $this->params = [];
        
        $sql[] = sprintf('DELETE FROM %s', $this->table->getTableName());
        $sql[] = $this->where->toSQL();
        $this->bind($this->where->getParams());

        return join(' ', $sql);
    }
1063859
public function deleteAll()
    {
        if ($this->loaded()) {
            $this->unload();
        }
        $this->hook('beforeDeleteAll');
        $this->controller->deleteAll($this);
        $this->hook('afterDeleteAll');

        return $this;
    }
262586
public function afterDelete ()
		{
			$parent = parent::afterDelete();

			if ($this->hasAttribute('order'))
			{
				$query = self::find()->where([ '>', 'order', $this->order ]);

				$condition = $this->orderCondition();
				if ($condition !== null)
				{
					$query->andWhere($condition);
				}

				$objects = $query->all();
				foreach ($objects as $object)
				{
					$object->order -= 1;
					$object->save();
				}
			}

			return $parent;
		}