/** * 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(FriendPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = FriendQuery::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; } }
/** * Checks whether an equal nest relation between Friend objects * * @param Personinteger $object1 * @param Person|integer $object2 * @param PropelPDO $con * @return Friend|false */ public static function checkForExistingEqualNestFriendRelation($object1, $object2, PropelPDO $con = null) { if ($object1 instanceof Person && $object1->isNew()) { return false; } if ($object2 instanceof Person && $object2->isNew()) { return false; } return ($relation = FriendQuery::create()->filterByPersons($object1, $object2)->findOne($con)) ? $relation : false; }
/** * Returns the number of related Friend objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Friend objects. * @throws PropelException */ public function countFriendsRelatedByPerson2(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collFriendsRelatedByPerson2Partial && !$this->isNew(); if (null === $this->collFriendsRelatedByPerson2 || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFriendsRelatedByPerson2) { return 0; } if ($partial && !$criteria) { return count($this->getFriendsRelatedByPerson2()); } $query = FriendQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByPersonRelatedByPerson2($this)->count($con); } return count($this->collFriendsRelatedByPerson2); }