コード例 #1
0
ファイル: BasePersonne.php プロジェクト: pauljenny/ginger
 /**
  * Returns the number of related Cotisation objects.
  *
  * @param Criteria $criteria
  * @param boolean $distinct
  * @param PropelPDO $con
  * @return int             Count of related Cotisation objects.
  * @throws PropelException
  */
 public function countCotisations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     $partial = $this->collCotisationsPartial && !$this->isNew();
     if (null === $this->collCotisations || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collCotisations) {
             return 0;
         } else {
             if ($partial && !$criteria) {
                 return count($this->getCotisations());
             }
             $query = CotisationQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByPersonne($this)->count($con);
         }
     } else {
         return count($this->collCotisations);
     }
 }
コード例 #2
0
 /**
  * Check the soft_delete behavior for this model
  * @return boolean true if the soft_delete behavior is enabled
  */
 public static function isSoftDeleteEnabled()
 {
     return CotisationQuery::isSoftDeleteEnabled();
 }
コード例 #3
0
 /**
  * Code to execute before every DELETE statement
  *
  * @param     PropelPDO $con The connection object used by the query
  */
 protected function basePreDelete(PropelPDO $con)
 {
     // soft_delete behavior
     if (CotisationQuery::isSoftDeleteEnabled() && $this->localSoftDelete) {
         return $this->softDelete($con);
     } else {
         return $this->hasWhereClause() ? $this->forceDelete($con) : $this->forceDeleteAll($con);
     }
     return $this->preDelete($con);
 }
コード例 #4
0
ファイル: BaseCotisation.php プロジェクト: pauljenny/ginger
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @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(CotisationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = CotisationQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // soft_delete behavior
         if (!empty($ret) && CotisationQuery::isSoftDeleteEnabled()) {
             $this->keepUpdateDateUnchanged();
             $this->setDeletedAt(time());
             $this->save($con);
             $this->postDelete($con);
             $con->commit();
             CotisationPeer::removeInstanceFromPool($this);
             return;
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #5
0
ファイル: Ginger.class.php プロジェクト: pauljenny/ginger
 public function getStats()
 {
     if (!$this->auth->getDroitCotisations()) {
         throw new ApiException(403);
     }
     $semestres = CotisationQuery::create()->withColumn("COUNT(*)", "Count")->groupByDebut()->orderByDebut()->find();
     $output = array();
     foreach ($semestres as $semestre) {
         if (isset($output[$this->dateToSemestre($semestre->getDebut())])) {
             $output[$this->dateToSemestre($semestre->getDebut())] += $semestre->getCount();
         } else {
             $output[$this->dateToSemestre($semestre->getDebut())] = $semestre->getCount();
         }
     }
     return $output;
 }