/**
  * Returns a new FriendQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   FriendQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return FriendQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof FriendQuery) {
         return $criteria;
     }
     $query = new FriendQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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;
     }
 }
Example #4
0
 /**
  * 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);
 }