Hi, I have problem.
I try to write function to change fields in DB when date exceeds specific date
I have DataObject "Obiekt"
<?php
class Obiekt extends DataObject {
static $db = array(
'NrObiektu' => 'Int',
'Title' => 'Varchar(255)',
...
'Created' => 'Date',
'Waznosc' => 'Date', //for when to display the object
"Status" => "Enum('Oplacony, Nieoplacony')",
);
static $indexes = array(
"URLSegment" => true
);
public function getCMSFields() {
$fields = parent::getCMSFields();
...
return $fields;
}
function onBeforeWrite() {
...
}
}
I don't know how write this and where placed this (maybe to function or init() or other place?)
Maybe by DB:: ?
Now I have to check date like this
$now = date('Y-m-d H:i:s');
$where = "Waznosc < '$now'";
I want to when $where is true change field Status from Oplacony to Nieoplacony
Sorry for my bad English