/** * Get the associated ChildPhrasebookCategories object * * @param ConnectionInterface $con Optional Connection object. * @return ChildPhrasebookCategories The associated ChildPhrasebookCategories object. * @throws PropelException */ public function getPhrasebookCategories(ConnectionInterface $con = null) { if ($this->aPhrasebookCategories === null && ($this->cat_id !== null && ($this->lang !== "" && $this->lang !== null))) { $this->aPhrasebookCategories = ChildPhrasebookCategoriesQuery::create()->findPk(array($this->cat_id, $this->lang), $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->aPhrasebookCategories->addPhrasebookPhrasess($this); */ } return $this->aPhrasebookCategories; }
/** * 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 = ChildPhrasebookCategoriesQuery::create(); $criteria->add(PhrasebookCategoriesTableMap::COL_ID, $this->id); $criteria->add(PhrasebookCategoriesTableMap::COL_LANG, $this->lang); return $criteria; }
$catsBase = Base\PhrasebookCategoriesQuery::create()->filterByLang($BASE)->orderBy("id")->find(); $categories = array(); foreach ($catsBase as $catBase) { $id = $catBase->getId(); $catLang = Base\PhrasebookCategoriesQuery::create()->findOneByIdAndLang($id, $lang); if ($catLang === NULL) { continue; } array_push($categories, array('id' => $catLang->getId(), $BASE => $catBase->getLabel(), $lang => $catLang->getLabel(), 'url' => $app->urlFor("category", array("lang" => $lang, "cat" => $catLang->getId())))); } $body = array('categories' => $categories); $app->response->header("content-type", "application/json"); $app->response->body(json_encode($body, JSON_UNESCAPED_SLASHES)); })->name('lang'); $app->get('/:lang/category/:cat', function ($lang, $catId) use($BASE, $app) { $category = Base\PhrasebookCategoriesQuery::create()->findOneByIdAndLang($catId, $BASE); if ($category == NULL) { $app->notFound(); return; } $baseLabel = $category->getLabel(); $category = \Base\PhrasebookCategoriesQuery::create()->findOneByIdAndLang($catId, $lang); if ($category === NULL) { $app->notFound(); return; } $body = array('category' => array('id' => $category->getId(), 'lang' => $category->getLang(), 'label' => array($BASE => $baseLabel, $lang => $category->getLabel()))); $app->response->header("content-type", "application/json"); $app->response->body(json_encode($body, JSON_UNESCAPED_SLASHES)); })->name('category'); $app->run();
/** * Returns a new ChildPhrasebookCategoriesQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildPhrasebookCategoriesQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildPhrasebookCategoriesQuery) { return $criteria; } $query = new ChildPhrasebookCategoriesQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }