protected static function getDb()
 {
     $db = Pimcore_Resource::getConnection();
     return $db;
 }
Exemple #2
0
 /**
  * Update question and answers.
  * @return Poll_Question
  * @throws Exception
  */
 protected function update()
 {
     $db = Pimcore_Resource::getConnection()->getResource();
     try {
         $db->beginTransaction();
         $answers = $this->getAnswers();
         foreach ($answers as $key => $answer) {
             if (in_array($answer->getId(), $this->_answersToDelete)) {
                 $answers->offsetUnset($key);
             } else {
                 $answer->save();
             }
         }
         if (count($answers) < 2) {
             $this->setIsActive(false);
         }
         $this->getResource()->update();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     return $this;
 }