Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Delete entry when date is expired

Go to End

2 Posts   645 Views


Community Member, 96 Posts

1 December 2011 at 1:47am


I´ve searched everywhere in web, but can´t find an solution.
I´m using DOM to save dates. Is it possible to delete the entries when the date is expired?
In php I can simply say: $query_delete_date = "DELETE FROM datetable WHERE date < DATE_SUB(NOW(), INTERVAL 1 DAY)";
But is there an nice way of writing a function into the DataObject-file?

Here´s my code from the DataObject:
$fields = singleton('Termin')->summaryFields();

class Termin extends DataObject
//db fields
static $db = array (
'Datum' => 'Date',
'Text' => 'Text'

static $has_one = array (
'Aktuelles' => 'Aktuelles',
'Author' => 'Member'

//Fields to show in the DOM table
static $summary_fields = array(

static $default_sort = "Datum ASC";

//Fields for the DOM Popup
public function getCMSFields()
return new FieldSet(
new DateField('Datum'),
new TextareaField('Text')


function onBeforeWrite(){
$currentMember = Member::currentMember();
$this->AuthorID = $currentMember->ID;

I hope someone can help me.


Community Member, 96 Posts

2 December 2011 at 2:09am

I figered out, that I can better use the filter clause in the DOM. So I wanna filter the dates that were older than today's date.

$terminmanager = new DataObjectManager(
$this->Datum < date('Y-m-d')

But this doesn´t work either. Does someone see the mistake?