/** * Returns a new ChildBookQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildBookQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \BookQuery) { return $criteria; } $query = new \BookQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * 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 = ChildBookQuery::create(); $criteria->add(BookTableMap::COL_ID, $this->id); return $criteria; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Author is new, it will return * an empty collection; or if this Author has previously * been saved, it will retrieve related Books from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Author. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return ObjectCollection|ChildBook[] List of ChildBook objects */ public function getBooksJoinPublisher(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildBookQuery::create(null, $criteria); $query->joinWith('Publisher', $joinBehavior); return $this->getBooks($query, $con); }
/** * Finds the related Book objects and keep them for later * * @param ConnectionInterface $con A connection object */ protected function findRelatedBookNumberOfVersess($con) { $criteria = clone $this; if ($this->useAliasInSQL) { $alias = $this->getModelAlias(); $criteria->removeAlias($alias); } else { $alias = ''; } $this->bookNumberOfVersess = \BookQuery::create()->joinVerse($alias)->mergeWith($criteria)->find($con); }
/** * Returns the number of related Book objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con * @return int Count of related Book objects. * @throws PropelException */ public function countBooks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collBooksPartial && !$this->isNew(); if (null === $this->collBooks || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collBooks) { return 0; } if ($partial && !$criteria) { return count($this->getBooks()); } $query = ChildBookQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByAuthor($this)->count($con); } return count($this->collBooks); }
/** * Get the associated ChildBook object * * @param ConnectionInterface $con Optional Connection object. * @return ChildBook The associated ChildBook object. * @throws PropelException */ public function getBook(ConnectionInterface $con = null) { if ($this->aBook === null && $this->book_id !== null) { $this->aBook = ChildBookQuery::create()->findPk($this->book_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aBook->addVerses($this); */ } return $this->aBook; }
/** * Removes this object from datastore and sets delete attribute. * * @param ConnectionInterface $con * @return void * @throws PropelException * @see Book::setDeleted() * @see Book::isDeleted() */ public function delete(ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getServiceContainer()->getWriteConnection(BookTableMap::DATABASE_NAME); } $con->beginTransaction(); try { $deleteQuery = ChildBookQuery::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; } }