![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 2 Pomógł: 0 Dołączył: 18.08.2011 Ostrzeżenie: (0%) ![]() ![]() |
Witam
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 } 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 CODE public function executeIndex(sfWebRequest $request) { $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 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. |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 395 Pomógł: 80 Dołączył: 24.08.2009 Ostrzeżenie: (0%) ![]() ![]() |
Tak na szybko bez testowania
Kod 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: Article: {foreignAllias: Categories, class: Article, refClass: Articletocategorie} -------------------- |
|
|
![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 86 Pomógł: 20 Dołączył: 20.01.2010 Ostrzeżenie: (0%) ![]() ![]() |
Generalnie takie bugi rozwiązuje się sprawdzając klasę BaseCategorieClass, tam masz wszystko napisane o relacjach i co jest jak zdefiniowane.
Dorzucę tylko, że masz błąd: foreignAllias: Categories (jedno l ma być) Myślę, że to będzie to, ale nie dam głowy. -------------------- -wdev-
|
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 2 Pomógł: 0 Dołączył: 18.08.2011 Ostrzeżenie: (0%) ![]() ![]() |
Toffiak - diękuje za zauważenie podstawowego błędu. Sprawdziłem jeszcze raz w dokumentacji Doctrine dla Many to Many i jest to oczywiste przeoczenie.
Wdev - dziękuje za znalezienie literówki. Teraz jestem w trakcie naprawy bazy danych i ponownej próby otrzymania Artykułów jednocześnie z Kategorią. |
|
|
![]() ![]() |
![]() |
Aktualny czas: 21.08.2025 - 19:28 |