public static function getNormalEvents($userId, $date, $minimalWeight = null) { $events = EventsQuery::create()->filterByIdUser($userId); if ($minimalWeight !== null) { $events = $events->where('events.event_weight >= ' . $minimalWeight); } $events = $events->orderByEventDate('asc')->findByEventDate($date); return $events; }
public function validateEvent($idEvent) { //Protection from accessing another user events $userId = $this->getUser()->getId(); $event = EventsQuery::create()->findPk($idEvent); if (!$event instanceof Events || $event->getIdUser() != $userId) { return false; } return true; }
/** * Gets the number of Events objects related by a many-to-many relationship * to the current object by way of the event_has_list cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param PropelPDO $con Optional connection object * * @return int the number of related Events objects */ public function countEventss($criteria = null, $distinct = false, PropelPDO $con = null) { if (null === $this->collEventss || null !== $criteria) { if ($this->isNew() && null === $this->collEventss) { return 0; } else { $query = EventsQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByCustomLists($this)->count($con); } } else { return count($this->collEventss); } }
/** * 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(EventsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = EventsQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Returns a new EventsQuery object. * * @param string $modelAlias The alias of a model in the query * @param EventsQuery|Criteria $criteria Optional Criteria to build the query from * * @return EventsQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof EventsQuery) { return $criteria; } $query = new EventsQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Get the associated Events object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Events The associated Events object. * @throws PropelException */ public function getEvents(PropelPDO $con = null, $doQuery = true) { if ($this->aEvents === null && $this->id_event !== null && $doQuery) { $this->aEvents = EventsQuery::create()->findPk($this->id_event, $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->aEvents->addEventHasLists($this); */ } return $this->aEvents; }