/** * Returns the number of related Turno objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Turno objects. * @throws PropelException */ public function countTurnos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collTurnosPartial && !$this->isNew(); if (null === $this->collTurnos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collTurnos) { return 0; } else { if ($partial && !$criteria) { return count($this->getTurnos()); } $query = TurnoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByJugadorMesa($this)->count($con); } } else { return count($this->collTurnos); } }
/** * 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(TurnoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = TurnoQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseTurno: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('BaseTurno: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; } }