00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Poll_Model_Mysql4_Poll_Vote extends Mage_Core_Model_Mysql4_Abstract
00036 {
00037 protected function _construct()
00038 {
00039 $this->_init('poll/poll_vote', 'vote_id');
00040 }
00041
00042
00043
00044
00045
00046
00047 protected function _afterSave(Mage_Core_Model_Abstract $object)
00048 {
00049
00050
00051
00052 $answerTable = $this->getTable('poll/poll_answer');
00053 $pollAnswerData = array('votes_count' => new Zend_Db_Expr('votes_count+1'));
00054 $condition = $this->_getWriteAdapter()->quoteInto("{$answerTable}.answer_id=?", $object->getPollAnswerId());
00055 $this->_getWriteAdapter()->update($answerTable, $pollAnswerData, $condition);
00056
00057
00058
00059
00060 $pollTable = $this->getTable('poll/poll');
00061 $pollData = array('votes_count' => new Zend_Db_Expr('votes_count+1'));
00062 $condition = $this->_getWriteAdapter()->quoteInto("{$pollTable}.poll_id=?", $object->getPollId());
00063 $this->_getWriteAdapter()->update($pollTable, $pollData, $condition);
00064 return $this;
00065 }
00066 }