Exemple #1
0
 /**
  * Gets the number of Batch objects related by a many-to-many relationship
  * to the current object by way of the R_batch_forbook cross-reference table.
  *
  * @param      Criteria $criteria Optional query object to filter the query
  * @param      boolean $distinct Set to true to force count distinct
  * @param      ConnectionInterface $con Optional connection object
  *
  * @return int the number of related Batch objects
  */
 public function countBatches(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collBatchesPartial && !$this->isNew();
     if (null === $this->collBatches || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collBatches) {
             return 0;
         } else {
             if ($partial && !$criteria) {
                 return count($this->getBatches());
             }
             $query = ChildBatchQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByBooks($this)->count($con);
         }
     } else {
         return count($this->collBatches);
     }
 }
Exemple #2
0
 /**
  * Returns a new ChildBatchQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildBatchQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildBatchQuery) {
         return $criteria;
     }
     $query = new ChildBatchQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Exemple #3
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildBatchQuery::create();
     $criteria->add(BatchTableMap::COL_ID, $this->id);
     return $criteria;
 }