/** * Returns the number of related ClockingType objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related ClockingType objects. * @throws PropelException */ public function countClockingTypes(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collClockingTypesPartial && !$this->isNew(); if (null === $this->collClockingTypes || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collClockingTypes) { return 0; } if ($partial && !$criteria) { return count($this->getClockingTypes()); } $query = ClockingTypeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByAccount($this)->count($con); } return count($this->collClockingTypes); }
/** * Returns a new ClockingTypeQuery object. * * @param string $modelAlias The alias of a model in the query * @param ClockingTypeQuery|Criteria $criteria Optional Criteria to build the query from * * @return ClockingTypeQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ClockingTypeQuery) { return $criteria; } $query = new ClockingTypeQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Get the associated ClockingType object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return ClockingType The associated ClockingType object. * @throws PropelException */ public function getClockingType(PropelPDO $con = null, $doQuery = true) { if ($this->aClockingType === null && $this->type_id !== null && $doQuery) { $this->aClockingType = ClockingTypeQuery::create()->filterByClocking($this)->findOne($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->aClockingType->addClockings($this); */ } return $this->aClockingType; }
/** * 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(ClockingTypePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ClockingTypeQuery::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; } }
/** * Lists all available clocking types. * * @param bool $wholeDayOnly Optional. Default is FALSE. * @return array */ public function do_types($wholeDayOnly = false) { $user = $this->requireUser(); $account = $user->getAccount(); if ($account === null) { throw new Exception('Could not determine account the authenticated user belongs to.'); } $query = ClockingTypeQuery::create()->filterByAccount($account); if ($wholeDayOnly) { $query->filterByWholeDay(true); } $result = array(); foreach ($query->find() as $type) { $result[] = EntityArray::from($type); } return $result; }