Mam zbudowany schemat oparty na relacji many to many.
CODE
Article:
actAs: {Timestampable: ~ }
columns:
id: { type: integer, primary: true, notnull: true, autoincrement: true }
name: { type: string(255), notnull: true }
short_description: { type: string(255) }
description: { type: string, notnull: true }
date_from: { type: timestamp }
date_to: { type: timestamp }
rewrite: { type: string(255), notnull: true }
view_num: { type: integer, default: 0 }
version: { type: integer, default: 0 }
Categorie:
actAs:
NestedSet:
hasManyRoots: true
rootColumnName: root_id
Sluggable:
fields: [rewrite]
columns:
id: { type: integer, primary: true, notnull: true, autoincrement: true }
name: { type: string(255), notnull: true }
rewrite: { type: string(255), notnull: true }
relations:
foreignAllias: Categories
class: Article
refClass: Articletocategorie
Articletocategorie:
columns:
categorie_id: { type: integer, primary: true, notnull: true }
article_id: { type: integer, primary: true, notnull: true }
relations:
Categorie: { onDelete: CASCADE, foreignAlias: ArticletoCategories }
Article: { onDelete: CASCADE, foreignAlias: ArticletoCategories }
actAs: {Timestampable: ~ }
columns:
id: { type: integer, primary: true, notnull: true, autoincrement: true }
name: { type: string(255), notnull: true }
short_description: { type: string(255) }
description: { type: string, notnull: true }
date_from: { type: timestamp }
date_to: { type: timestamp }
rewrite: { type: string(255), notnull: true }
view_num: { type: integer, default: 0 }
version: { type: integer, default: 0 }
Categorie:
actAs:
NestedSet:
hasManyRoots: true
rootColumnName: root_id
Sluggable:
fields: [rewrite]
columns:
id: { type: integer, primary: true, notnull: true, autoincrement: true }
name: { type: string(255), notnull: true }
rewrite: { type: string(255), notnull: true }
relations:
foreignAllias: Categories
class: Article
refClass: Articletocategorie
Articletocategorie:
columns:
categorie_id: { type: integer, primary: true, notnull: true }
article_id: { type: integer, primary: true, notnull: true }
relations:
Categorie: { onDelete: CASCADE, foreignAlias: ArticletoCategories }
Article: { onDelete: CASCADE, foreignAlias: ArticletoCategories }
Wygenerowane są dwa moduły Article oraz Categorie. Bazując na module Categorie chcę wywołać tabelę Article jednocześnie z tabelą Categorie.
W tym celu w CategorieTable.class.php dodałem funkcję
CODE
public function getwithArticle()
W akcji - action.class.php zmodyfikowałem executeIndex
{
$q = $this->createQuery('c')
->leftJoin('c.Article');
return $q->execute();
}
W akcji - action.class.php zmodyfikowałem executeIndex
CODE
public function executeIndex(sfWebRequest $request)
{
$this->categories = Doctrine_Core::getTable('Categorie')->getwithArticle();
}
{
$this->categories = Doctrine_Core::getTable('Categorie')->getwithArticle();
}
{
$q = $this->createQuery('c')
->leftJoin('c.Article');
return $q->execute();
}
Nie modyfikując już nawet IndexSuccess.php wywołałem stronę i otrzymałem błąd Doctrine.
500 | Internal Server Error | Doctrine_Table_Exception
Unknown relation alias Article
Unknown relation alias Article
Jest to moja pierwsza przygoda z Symfony.
Swoją wiedzę ciąglę rozbudowuję korzystając z dokumentacji na http://www.symfony-project.org, http://www.doctrine-project.org, oraz innych przyjaznych portali.
Nie potrafię znaleźć tam odpowwiedzi.
Moja desperacja doprowadziła do stworzenia przeróżnych akcji oraz modyfikacji modułów Categorii oraz Article. Ciągle otrzymując ten błąd.
Błądzenie po omacku zaczyna mijać się z celem.
Proszę o sugestię. Ewentualnie jak prawidłowo powinienem pobrać treść artykułu znajdującego się w danej kategorii.