示例#1
0
 public function hasMember($userId)
 {
     $c = new Criteria();
     $c->add(UsergroupHasUserPeer::USERGROUP_ID, $this->getId(), Criteria::EQUAL);
     $c->addAnd(UsergroupHasUserPeer::USER_ID, $userId, Criteria::EQUAL);
     return UsergroupHasUserPeer::doCount($c) > 0;
 }
示例#2
0
 /**
  * Returns the number of related UsergroupHasUser objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related UsergroupHasUser objects.
  * @throws     PropelException
  */
 public function countUsergroupHasUsers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collUsergroupHasUsers === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(UsergroupHasUserPeer::USER_ID, $this->id);
             $count = UsergroupHasUserPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(UsergroupHasUserPeer::USER_ID, $this->id);
             if (!isset($this->lastUsergroupHasUserCriteria) || !$this->lastUsergroupHasUserCriteria->equals($criteria)) {
                 $count = UsergroupHasUserPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collUsergroupHasUsers);
             }
         } else {
             $count = count($this->collUsergroupHasUsers);
         }
     }
     return $count;
 }