/** * Gets an array of BlogTagArticle objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this BlogArticle has previously been saved, it will retrieve * related BlogTagArticles from storage. If this BlogArticle is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array BlogTagArticle[] * @throws PropelException */ public function getBlogTagArticles($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(BlogArticlePeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collBlogTagArticles === null) { if ($this->isNew()) { $this->collBlogTagArticles = array(); } else { $criteria->add(BlogTagArticlePeer::ARTICLE_ID, $this->id); BlogTagArticlePeer::addSelectColumns($criteria); $this->collBlogTagArticles = BlogTagArticlePeer::doSelect($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 the collection. $criteria->add(BlogTagArticlePeer::ARTICLE_ID, $this->id); BlogTagArticlePeer::addSelectColumns($criteria); if (!isset($this->lastBlogTagArticleCriteria) || !$this->lastBlogTagArticleCriteria->equals($criteria)) { $this->collBlogTagArticles = BlogTagArticlePeer::doSelect($criteria, $con); } } } $this->lastBlogTagArticleCriteria = $criteria; return $this->collBlogTagArticles; }
/** * Retrieve object using using composite pkey values. * @param int $tag_id @param int $article_id * @param PropelPDO $con * @return BlogTagArticle */ public static function retrieveByPK($tag_id, $article_id, PropelPDO $con = null) { $key = serialize(array((string) $tag_id, (string) $article_id)); if (null !== ($obj = BlogTagArticlePeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(BlogTagArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(BlogTagArticlePeer::DATABASE_NAME); $criteria->add(BlogTagArticlePeer::TAG_ID, $tag_id); $criteria->add(BlogTagArticlePeer::ARTICLE_ID, $article_id); $v = BlogTagArticlePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }