Exemplo n.º 1
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database. In some cases you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by find*()
  * and findPk*() calls.
  *
  * @param \RatingValue $obj A \RatingValue object.
  * @param string $key             (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if (null === $key) {
             $key = serialize(array((string) $obj->getRatingHeaderId(), (string) $obj->getCategoryOptionId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Exemplo n.º 2
0
         }
         $value = new RatingValue();
         $value->setRatingHeader($header);
         $value->setCategoryOption($option);
         $value->setOriginalValue($option->getValue());
         if ($selected == "adns") {
             $value->setDoNotScore(true);
         }
         if (array_key_exists('comment_' . $option->getId(), $_POST)) {
             $value->setComments($_POST['comment_' . $option->getId()]);
         } else {
             $value->setComments("");
         }
         $value->save($con);
         if (array_key_exists('sub_option_' . $option->getId(), $_POST)) {
             $sub_value = new RatingValue();
             $sub_value->setRatingHeader($header);
             $sub_option = CategoryOptionQuery::create()->filterById($_POST['sub_option_' . $option->getId()])->findOne($con);
             if ($sub_option == null) {
                 throw new Exception("Sub option ID not found: " . $_POST['sub_option_' . $option->getId()]);
             }
             $sub_value->setCategoryOption($sub_option);
             $sub_value->setOriginalValue($sub_option->getValue());
             $sub_value->save($con);
             $score += $sub_option->getValue();
         }
         if (!$value->getDoNotScore()) {
             $score += $option->getValue();
         }
     }
 }