/** * Returns a new CourtQuery object. * * @param string $modelAlias The alias of a model in the query * @param CourtQuery|Criteria $criteria Optional Criteria to build the query from * * @return CourtQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof CourtQuery) { return $criteria; } $query = new CourtQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Gets the number of Court objects related by a many-to-many relationship * to the current object by way of the player_court 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 Court objects */ public function countCourts($criteria = null, $distinct = false, PropelPDO $con = null) { if (null === $this->collCourts || null !== $criteria) { if ($this->isNew() && null === $this->collCourts) { return 0; } else { $query = CourtQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByPlayer($this)->count($con); } } else { return count($this->collCourts); } }
/** * Returns the number of related Court objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Court objects. * @throws PropelException */ public function countCourts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collCourtsPartial && !$this->isNew(); if (null === $this->collCourts || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCourts) { return 0; } if ($partial && !$criteria) { return count($this->getCourts()); } $query = CourtQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByCorporation($this)->count($con); } return count($this->collCourts); }
/** * Get the associated Court object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Court The associated Court object. * @throws PropelException */ public function getCourt(PropelPDO $con = null, $doQuery = true) { if ($this->aCourt === null && $this->court_id !== null && $doQuery) { $this->aCourt = CourtQuery::create()->findPk($this->court_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->aCourt->addPlayerCourts($this); */ } return $this->aCourt; }
/** * 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(CourtPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = CourtQuery::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; } }