World.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /** @package HelloWorld::Model */
  3. /** import supporting libraries */
  4. require_once("DAO/WorldDAO.php");
  5. require_once("WorldCriteria.php");
  6. /**
  7. * The World class extends WorldDAO which provides the access
  8. * to the datastore.
  9. *
  10. * @package HelloWorld::Model
  11. * @author ClassBuilder
  12. * @version 1.0
  13. */
  14. class World extends WorldDAO
  15. {
  16. /**
  17. * Override default validation
  18. * @see Phreezable::Validate()
  19. */
  20. public function Validate()
  21. {
  22. // example of custom validation
  23. // $this->ResetValidationErrors();
  24. // $errors = $this->GetValidationErrors();
  25. // if ($error == true) $this->AddValidationError('FieldName', 'Error Information');
  26. // return !$this->HasValidationErrors();
  27. return parent::Validate();
  28. }
  29. /**
  30. * @see Phreezable::OnSave()
  31. */
  32. public function OnSave($insert)
  33. {
  34. // the controller create/update methods validate before saving. this will be a
  35. // redundant validation check, however it will ensure data integrity at the model
  36. // level based on validation rules. comment this line out if this is not desired
  37. // if (!$this->Validate()) throw new Exception('Unable to Save World: ' . implode(', ', $this->GetValidationErrors()));
  38. // OnSave must return true or eles Phreeze will cancel the save operation
  39. return true;
  40. }
  41. /**
  42. * @return multitype:NULL boolean
  43. */
  44. public function ToObject($options = null)
  45. {
  46. $obj = array('id'=>$this->Id,'randomNumber'=>$this->Randomnumber);
  47. return $obj;
  48. }
  49. }
  50. ?>