Пример #1
0
 public function executeListarPorCategoria(sfWebRequest $requets)
 {
     $cat = $requets->getParameter('id');
     $nomCat = CategoriaQuery::create();
     $nomCat->filterById($cat);
     $this->categoria = $nomCat->findOne();
     //logica de negocio: no_autenticados o menores NO xxx
     if ($cat == 8) {
         if (!$this->getUser()->isAuthenticated()) {
             $this->mje = "Usted no esta logueado, no puede acceder a esta sección!";
             return sfView::ERROR;
         } else {
             $edad = $this->getUser()->getAttribute('edad');
             if ($edad < 18) {
                 $this->mje = "Usted es menor de edad y no puede acceder a esta sección!";
                 return sfView::ERROR;
             }
         }
     }
     //10 es el numero de registros que deseo mostrar
     $paginacion = new sfPropelPager('Pelicula', 10);
     $sql = new Criteria();
     $sql->add(PeliculaPeer::CATEGORIA_ID, $cat, Criteria::EQUAL);
     $sql->addAscendingOrderByColumn(PeliculaPeer::TITULO);
     $sql->addGroupByColumn(PeliculaPeer::TITULO);
     $paginacion->setCriteria($sql);
     $paginacion->setPage($this->getRequestParameter('pag', 1));
     $paginacion->init();
     $this->peliculas = $paginacion;
     /*$cat = $requets->getParameter('id');
       $nomCat = CategoriaQuery::create();
       $nomCat->filterById($cat);
       $this->categoria = $nomCat->findOne();
       if ($cat == 8){
           if(!$this->getUser()->isAuthenticated()){
               $this->mje = "Usted no esta logueado, no puede acceder a esta sección!";
               return sfView::ERROR;
           }else{
             $edad = $this->getUser()->getAttribute('edad');
             if($edad < 18){
                 $this->mje = "Usted es menor de edad y no puede acceder a esta sección!";
                 return sfView::ERROR;
             }
           }
       }
       $this->peliculas = PeliculaQuery::create()
               ->filterByEstado('1')
               ->filterByCategoriaId($cat)
               ->groupByTitulo()
               ->find();
        * 
        */
 }
Пример #2
0
 public function executeObtCategorias()
 {
     $categ = CategoriaQuery::create();
     $this->categorias = $categ->find();
 }
Пример #3
0
 /**
  * Get the associated Categoria object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Categoria The associated Categoria object.
  * @throws     PropelException
  */
 public function getCategoria(PropelPDO $con = null)
 {
     if ($this->aCategoria === null && $this->categoria_id !== null) {
         $this->aCategoria = CategoriaQuery::create()->findPk($this->categoria_id, $con);
         /* The following can be used additionally to
         			guarantee the related object contains a reference
         			to this object.  This level of coupling may, however, be
         			undesirable since it could result in an only partially populated collection
         			in the referenced object.
         			$this->aCategoria->addPeliculas($this);
         		 */
     }
     return $this->aCategoria;
 }
Пример #4
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(CategoriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = CategoriaQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // symfony_behaviors behavior
         foreach (sfMixer::getCallables('BaseCategoria:delete:pre') as $callable) {
             if (call_user_func($callable, $this, $con)) {
                 $con->commit();
                 return;
             }
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             // symfony_behaviors behavior
             foreach (sfMixer::getCallables('BaseCategoria:delete:post') as $callable) {
                 call_user_func($callable, $this, $con);
             }
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }