protected function beforeSave() { if (parent::beforeSave()) { if ($this->isNewRecord()) { if (!isset($this->create_time)) { $this->setAttribute('create_time', time()); } if (!isset($this->frequency)) { $this->setAttribute('frequency', 1); } } return true; } return false; }
/** * Sets up the fixture before executing a test method. * If you override this method, make sure the parent implementation is invoked. * Otherwise, the database fixtures will not be managed properly. */ public function setUp() { parent::setUp(); if (is_array($this->fixtures)) { foreach ($this->fixtures as $fixtureName => $modelClass) { $tableName = WF_Table::model($modelClass)->tableName(); $this->resetTable($tableName); $rows = $this->loadFixtures($modelClass, $tableName); if (is_array($rows) && is_string($fixtureName)) { $this->_rows[$fixtureName] = $rows; if (isset($modelClass)) { foreach (array_keys($rows) as $alias) { $this->_records[$fixtureName][$alias] = $modelClass; } } } } } }
public static function model($className = __CLASS__) { return parent::model($className); }
public function beforeSave() { if (parent::beforeSave()) { if ($this->create_time <= 0) { $this->create_time = $this->update_time = time(); return true; } $this->update_time = time(); return true; } return false; }