Advertisement
Guest User

Untitled

a guest
May 25th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. class Poll
  2. {
  3.   public function save()
  4.   {
  5.     if( id !== null )
  6.        $this->update();
  7.     else
  8.        $this->insert();
  9.   }
  10.  
  11.   public function saveOptions()
  12.   {
  13.      // save options
  14.     for( $i=0; $i<$this->options->count(); $i++ )
  15.        $this->getOptionAt($i)->save();
  16.   }
  17. }
  18.  
  19. class PollOption
  20. {
  21.   public function save()
  22.   {
  23.       if( id !== null )
  24.           $this->update();
  25.       else
  26.           $this->insert();
  27.   }
  28. }
  29.  
  30. $poll = new Poll();
  31. $poll->stand('Wat is de leukste programmeertaal');
  32. $poll->save();
  33.  
  34. $option = new PollOption();
  35. $option->text('C#');
  36. $poll->addOption($option);
  37.  
  38. $option = new PollOption();
  39. $option->text('C++');
  40. $poll->addOption($option);
  41.  
  42. $poll->saveOptions();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement