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.

Data Model Questions

Can't write a ssdatetime value...


Reply

2 Posts   2161 Views

Avatar
LesC

12 May 2009 at 12:07am Community Member, 70 Posts

Hi folks,

I'm trying to run a function every so often instead of every time a page is called (it's parsing an xml feed that can't take very many hits per hour), but can't get one part of it working.

I've got a value of LastUpdated, am testing against that to the current time -3 hours, running the XML parser function, then saving the current time as the LastUpdated value.

Problem is it doesn't save the LastUpdated value and I'm at a loss to know what's going on! The LastUpdated value is a SSDatetime if that makes any difference?

// in the class
public static $db = array (
'LastUpdated' => 'SSDatetime'
);

// in the controller
public function getEntries() {
// call $this->updateEntries() if this holder has not been updated in the last 3 hours
if(strtotime($this->LastUpdated) < strtotime('-3 hours')) {
$this->updateEntries();
$this->LastUpdated = date("Y-m-d H:i:s",time());
$this->write();
}
}

Avatar
ilyabr

21 May 2009 at 2:56pm Community Member, 2 Posts

I had the same problem. Adding

public static $casting = array(
"LastUpdated" => "SSDatetime"
);

in the class, after the field definition, helped.