FOF30\Model\DataModel::forceDelete PHP Method

forceDelete() public method

Delete a record, either the currently loaded one or the one specified in $id. If an $id is specified that record is loaded before trying to delete it. In the end the data model is reset.
public forceDelete ( mixed $id = null )
$id mixed Primary key (id field) value
    public function forceDelete($id = null)
    {
        if (!empty($id)) {
            $this->findOrFail($id);
        }
        $id = $this->getId();
        if (!$id) {
            throw new RecordNotLoaded("Can't delete a not loaded DataModel object");
        }
        $this->triggerEvent('onBeforeDelete', array(&$id));
        $db = $this->getDbo();
        $query = $db->getQuery(true)->delete()->from($this->tableName)->where($db->qn($this->idFieldName) . ' = ' . $db->q($id));
        $db->setQuery($query)->execute();
        $this->triggerEvent('onAfterDelete', array(&$id));
        $this->reset();
        return $this;
    }