Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Poll
- {
- public function save()
- {
- if( id !== null )
- $this->update();
- else
- $this->insert();
- }
- public function saveOptions()
- {
- // save options
- for( $i=0; $i<$this->options->count(); $i++ )
- $this->getOptionAt($i)->save();
- }
- }
- class PollOption
- {
- public function save()
- {
- if( id !== null )
- $this->update();
- else
- $this->insert();
- }
- }
- $poll = new Poll();
- $poll->stand('Wat is de leukste programmeertaal');
- $poll->save();
- $option = new PollOption();
- $option->text('C#');
- $poll->addOption($option);
- $option = new PollOption();
- $option->text('C++');
- $poll->addOption($option);
- $poll->saveOptions();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement