diff options
author | Dracony <draconyster@gmail.com> | 2013-01-18 18:53:33 +0200 |
---|---|---|
committer | Dracony <draconyster@gmail.com> | 2013-01-18 18:53:33 +0200 |
commit | 65a7f45a570dde73e1ca1fefc1af15491772e8fc (patch) | |
tree | 104be63aacdbb8683358e79b8475d0c307cd0fb2 /application/classes/model | |
parent | 0a162ebe5ca518754fbe4668db39758cacbd5d4b (diff) | |
download | PHPixie-65a7f45a570dde73e1ca1fefc1af15491772e8fc.zip PHPixie-65a7f45a570dde73e1ca1fefc1af15491772e8fc.tar.gz PHPixie-65a7f45a570dde73e1ca1fefc1af15491772e8fc.tar.bz2 |
some testing
Diffstat (limited to 'application/classes/model')
-rw-r--r-- | application/classes/model/option.php | 12 | ||||
-rw-r--r-- | application/classes/model/poll.php | 13 |
2 files changed, 25 insertions, 0 deletions
diff --git a/application/classes/model/option.php b/application/classes/model/option.php new file mode 100644 index 0000000..b143913 --- /dev/null +++ b/application/classes/model/option.php @@ -0,0 +1,12 @@ +<?php
+class Option_Model extends ORM{
+ public $belongs_to = array('poll');
+
+ public function get($property) {
+ if ($property == 'percent') {
+ if($this->poll->total_votes==0)
+ return 0;
+ return floor($this->votes/$this->poll->total_votes*100);
+ }
+ }
+}
\ No newline at end of file diff --git a/application/classes/model/poll.php b/application/classes/model/poll.php new file mode 100644 index 0000000..a2cfe08 --- /dev/null +++ b/application/classes/model/poll.php @@ -0,0 +1,13 @@ +<?php
+class Poll_Model extends ORM{
+ public $has_many=array('options');
+
+ public function get($property){
+ if ($property == 'total_votes') {
+ $total=0;
+ foreach($this->options->find_all() as $option)
+ $total += $option->votes;
+ return $total;
+ }
+ }
+}
\ No newline at end of file |