public function findOrCreateOne($tag_type_value) { # Attempt to find tag type $tag_type = TagTypeQuery::create()->filterByValue($tag_type_value)->findOne(); # Return or create tag type if ($tag_type) { return $tag_type; } else { $tag_type = new TagType(); $tag_type->setValue($tag_type_value)->save(); return $tag_type; } }
function find_tag_type($tag_type_value) { # Find type $tag_type = TagTypeQuery::create()->findOrCreateOne($tag_type_value); # Return type return $tag_type; }
/** * 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 = ChildTagTypeQuery::create(); $criteria->add(TagTypeTableMap::COL_ID, $this->id); return $criteria; }
/** * Get the associated ChildTagType object * * @param ConnectionInterface $con Optional Connection object. * @return ChildTagType The associated ChildTagType object. * @throws PropelException */ public function getTagType(ConnectionInterface $con = null) { if ($this->aTagType === null && $this->type_id !== null) { $this->aTagType = ChildTagTypeQuery::create()->findPk($this->type_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->aTagType->addTags($this); */ } return $this->aTagType; }