/** * * Refreshes data for this record from the database. * * Note that this does not refresh any related or calculated values. * * @return void * */ public function refresh() { if ($this->isNew()) { throw $this->_exception('ERR_CANNOT_REFRESH_NEW_RECORD'); } if ($this->isDeleted()) { throw $this->_exception('ERR_DELETED'); } $id = $this->getPrimaryVal(); if (!$id) { throw $this->_exception('ERR_CANNOT_REFRESH_BLANK_ID'); } $result = $this->_model->fetch($id); foreach ($this->_model->table_cols as $col => $info) { $this->_data[$col] = $result->_data[$col]; } // note record is refreshed $this->_setSqlStatus(self::SQL_STATUS_REFRESHED); // cannot be dirty or invalid at this point $this->_is_dirty = false; $this->_invalid = array(); }