public function executeDeletechapter()
 {
     $chapter = ChapterPeer::retrieveByPK($this->getRequestParameter('id'));
     $cr = $chapter->getChapterregion();
     $c = new Criteria();
     $c->add(UserchapterregionPeer::CHAPTERREGION_ID, $cr->getId());
     $ucount = UserchapterregionPeer::doCount($c);
     $ucr = UserchapterregionPeer::doSelectOne($c);
     if ($ucr) {
         $this->setFlash('notice', 'Cannot delete chapter. <b>' . $ucount . '</b> user(s) are subscribed to this chapter.');
     } else {
         $chapter->delete();
         $cr->delete();
         $this->setFlash('notice', 'Chapter Deleted Successfully');
     }
     $this->redirect('admin/chapters');
 }
 public function getChapter($con = null)
 {
     include_once 'lib/model/om/BaseChapterPeer.php';
     if ($this->aChapter === null && $this->chapter_id !== null) {
         $this->aChapter = ChapterPeer::retrieveByPK($this->chapter_id, $con);
     }
     return $this->aChapter;
 }
Exemple #3
0
 public function getChapter()
 {
     $c = new Criteria();
     $c->addJoin(UserchapterregionPeer::CHAPTERREGION_ID, ChapterregionPeer::ID);
     $c->addJoin(ChapterregionPeer::CHAPTER_ID, ChapterPeer::ID);
     $c->add(UserchapterregionPeer::USER_ID, $this->id);
     return ChapterPeer::doSelect($c);
 }
 public static function doSelectJoinAllExceptRegion(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ChapterregionPeer::addSelectColumns($c);
     $startcol2 = ChapterregionPeer::NUM_COLUMNS - ChapterregionPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     ChapterPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + ChapterPeer::NUM_COLUMNS;
     $c->addJoin(ChapterregionPeer::CHAPTER_ID, ChapterPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = ChapterregionPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = ChapterPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getChapter();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addChapterregion($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initChapterregions();
             $obj2->addChapterregion($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ChapterPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
 }
 public function executeChapter()
 {
     $this->clearattrib();
     $c = new Criteria();
     $c->addAscendingOrderByColumn(ChapterPeer::NAME);
     $this->chapters = ChapterPeer::doSelect($c);
 }
    if ($br) {
        echo "<b>" . BranchPeer::retrieveByPK($br)->getName() . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Year: <?php 
    if ($yr) {
        echo "<b>" . $yr . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Chapter: <?php 
    if ($chap) {
        echo "<b>" . ChapterPeer::retrieveByPK($chap)->getname() . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Location: <?php 
    if ($loc) {
        echo "<b>" . $loc . "</b>";
    } else {
        echo '<i>any</i>';
    }
    ?>
				<br>Country: <?php 
    if ($cn) {
        echo "<b>" . CountryPeer::retrieveByPK($cn)->getname() . "</b>";
    } else {
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ChapterPeer::ID, $pks, Criteria::IN);
         $objs = ChapterPeer::doSelect($criteria, $con);
     }
     return $objs;
 }