/**
  * Returns a new ChildAuthorQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildAuthorQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof \AuthorQuery) {
         return $criteria;
     }
     $query = new \AuthorQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 /**
  * Get the associated ChildAuthor object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildAuthor The associated ChildAuthor object.
  * @throws PropelException
  */
 public function getAuthor(ConnectionInterface $con = null)
 {
     if ($this->aAuthor === null && $this->author_id !== null) {
         $this->aAuthor = ChildAuthorQuery::create()->findPk($this->author_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->aAuthor->addBooks($this);
            */
     }
     return $this->aAuthor;
 }
Example #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 = ChildAuthorQuery::create();
     $criteria->add(AuthorTableMap::COL_ID, $this->id);
     return $criteria;
 }
Example #4
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see Author::setDeleted()
  * @see Author::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(AuthorTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildAuthorQuery::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;
     }
 }