Exemplo n.º 1
0
 /**
  * Returns the number of related Element objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Element objects.
  * @throws     PropelException
  */
 public function countElements(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collElements === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(ElementPeer::CATEGORY_ID, $this->id);
             $count = ElementPeer::doCount($criteria, false, $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(ElementPeer::CATEGORY_ID, $this->id);
             if (!isset($this->lastElementCriteria) || !$this->lastElementCriteria->equals($criteria)) {
                 $count = ElementPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collElements);
             }
         } else {
             $count = count($this->collElements);
         }
     }
     return $count;
 }
 /**
  * Returns the number of related Elements.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      Connection $con
  * @throws     PropelException
  */
 public function countElements($criteria = null, $distinct = false, $con = null)
 {
     // include the Peer class
     include_once 'src/model/whiteboard/om/BaseElementPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(ElementPeer::PRODUCTION_ID, $this->getProductionId());
     return ElementPeer::doCount($criteria, $distinct, $con);
 }