1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace Cas\Dao;
- use KIF\Dao\DBAgileDev;
- use KIF\Core\Request;
- use KIF\Cache\Memcached;
- /**
- *
- * 活动[投票]
- *
- * @author lihuanchun@qq.com
- *
- */
- class LotteryEventsVote extends DBAgileDev {
- protected $tableName = 'lottery_events_vote';
-
-
- /**
- * 数据库里的真实字段
- * @var array
- */
- protected $other_field = array(
- 'events_id',
- 'title',
- 'img_url',
- 'num',
- 'add_num'
- );
-
- /**
- * 获取当前活动的投票数据
- */
- public function getThisEventData($events_id){
- $condition = array(
- 'events_id' => $events_id
- );
- $ids = $this->findIdsBy($condition);
-
- if(!$ids){
- return null;
- }
- return $this->gets($ids);
- }
-
- /**
- * 投票数增加
- */
- public function upNum($id,$num=1){
- $data = $this->get($id);
- $info = array(
- 'num' => $data['num'] + $num
- );
- return $this->modify($info,array('id' => $id));
- }
-
- /**
- * 投票数递减
- * @param unknown $id
- * @param number $num
- * @return Ambigous <\KIF\Data\ResultWrapper, \KIF\Data\ResultWrapper>
- */
- public function decrNum($id, $num = 1) {
- $data = $this->get($id);
- $info = array(
- 'num' => $data['num'] - $num
- );
- return $this->modify($info,array('id' => $id));
- }
- }
|