/**
  * 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 -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      CourseDetail $value A CourseDetail object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(CourseDetail $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Exemple #2
0
 protected function parseDetails(sfForm $courseDetailform, Course $course)
 {
     if ($courseDetailform['hasDetail']->getValue() == '1') {
         if ($courseDetailform->isValid()) {
             // save the course_detail object
             $detailDescr = $courseDetailform['detail_descr']->getValue();
             $firstOffered = $courseDetailform["first_offered"]->getValue();
             $lastOffered = $courseDetailform["last_offered"]->getValue();
             $arr = $course->getCourseDetails();
             if ($arr != null && count($arr) == 1) {
                 // replace the existing object with the new one
                 $detailObj = $arr[0];
             } elseif ($arr !== null && count($arr) > 1) {
                 //FIXME: multiple courseDetail objects.
                 throw new Exception("Multiple course detail objects found.");
             } else {
                 // insert a new object
                 $detailObj = new CourseDetail();
                 $detailObj->setCourseId($course->getId());
             }
             $detailObj->setDetailDescr($detailDescr);
             $detailObj->setFirstOffered($firstOffered);
             $detailObj->setLastOffered($lastOffered);
             $detailObj->save();
             return true;
         } else {
             return false;
         }
     } else {
         $this->omitdetailerr = true;
         // delete the course_detail object if it exists
         $arr = $course->getCourseDetails();
         if ($arr !== null) {
             foreach ($arr as $detailObj) {
                 $detailObj->delete();
             }
         }
         return true;
     }
 }