Example #1
0
 function updateData($data)
 {
     if (empty($data['pid']) || empty($data['sid']) || empty($data['value'])) {
         return false;
     }
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     if (!$identity) {
         return false;
     }
     $data['user_id'] = $identity->id;
     $this->addTechInfo($data, array('info' => true));
     $res = $this->_updateData($data, array('notify' => false, 'upload' => false));
     #, array('test' => 1)
     if ($res) {
         // update stat via TRIGGER!
         // http://www.wddx.ru/2010/07/count-vs.html
         $a = $this->countVotes($data);
         if ($a) {
             switch ($data['sid']) {
                 case 3:
                     $positions = new Positions();
                     $update = array('rating' => $a['avg'], 'votes' => $a['cnt']);
                     #l($data);
                     // UPDATE c_positions SET rating = '3.5000', votes = 2 WHERE id = 3;
                     #$where = $this->getAdapter()->quoteInto('id = ?', $data['pid']);
                     $res = $positions->update($update, 'id=' . $data['pid']);
                     break;
             }
         }
     }
     return $res;
 }