Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z JOIN LEFT: Doctrine_Table_Exception: Unknown relation alias
tejek
post 8.06.2011, 13:09:30
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 12.11.2005

Ostrzeżenie: (0%)
-----


Witam,

Od pewnego czasu męczę się z MySql, Doctrine i JOINLEFT. Mój plik schema.yml wygląda tak: (w zasadzie jest to kawałek tego pliku. Plik generuje przy pomocy WorkBench-a)

  1. ---
  2. detect_relations: true
  3. options:
  4. collate: utf8_polish_ci
  5. charset: utf8
  6. type: InnoDB
  7.  
  8. User:
  9. tableName: Users
  10. COLUMNS:
  11. id:
  12. type: integer(4)
  13. PRIMARY: true
  14. notnull: true
  15. autoincrement: true
  16. username:
  17. type: string(45)
  18. notnull: true
  19. password:
  20. type: string(45)
  21. notnull: true
  22. email:
  23. type: string(45)
  24. notnull: true
  25. phone:
  26. type: string(100)
  27. notnull: true
  28. type:
  29. type: enum
  30. VALUES: ['u','a']
  31. DEFAULT: 'u'
  32. active:
  33. type: integer(1)
  34. DEFAULT: 0
  35. blocked:
  36. type: integer(1)
  37. DEFAULT: 0
  38. options:
  39. charset: utf8
  40. collate: utf8_polish_ci
  41.  
  42. UsersDetail:
  43. tableName: UsersDetails
  44. COLUMNS:
  45. user_detail_id:
  46. type: integer(4)
  47. PRIMARY: true
  48. notnull: true
  49. autoincrement: true
  50. Users_id:
  51. type: integer(4)
  52. notnull: true
  53. name:
  54. type: string(45)
  55. surname:
  56. type: string(45)
  57. address:
  58. type: string(255)
  59. city:
  60. type: string(45)
  61. postcode:
  62. type: string(45)
  63. birthdate:
  64. type: string(45)
  65. relations:
  66. User:
  67. class: User
  68. LOCAL: Users_id
  69. FOREIGN: id
  70. foreignAlias: UsersDetails
  71. options:
  72. charset: utf8
  73. collate: utf8_polish_ci


Natomiast moje zapytanie do bazy wygląda następująco:
  1. $data = Doctrine_Query::create()->from('Model_User u')->select('u.*,d.*')
  2. ->leftJoin('u.Model_UsersDetail d ON d.Users_id=u.id')
  3. ->fetchArray();


Co robię źle, że wyrzuca mi taki błąd: Doctrine_Table_Exception: Unknown relation alias Model_UsersDetail??
Go to the top of the page
+Quote Post
toffiak
post 8.06.2011, 16:17:15
Post #2





Grupa: Zarejestrowani
Postów: 395
Pomógł: 80
Dołączył: 24.08.2009

Ostrzeżenie: (0%)
-----


Nie widzę nigdzie klas Model_User i Model_UsersDetail
spróbuj tak
  1. $data = Doctrine_Query::CREATE()->select('u.*,d.*')->from('User u')->leftJoin('u.UsersDetail d')
  2. ->fetchArray();


Ten post edytował toffiak 8.06.2011, 16:18:13


--------------------
Go to the top of the page
+Quote Post
tejek
post 8.06.2011, 19:21:34
Post #3





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 12.11.2005

Ostrzeżenie: (0%)
-----


To nie będzie to, nazwy class modeli są poprawne, bo podczas generowania Modeli dodaje do każdej nazwy tabeli która jest pobierana z pliku yml przedrostek Model_ dlatego nazwy się różnią.

Jednak mam pytanie, a zarazem prośbę czy mógłby ktoś sprawdzić czy w moim pliku .yml poprawnie zadeklarowałem relacje. W sumie plik .yml tworzyłem przy pomocy workbench-a jednak maszyny też się czasem mylą, a ja już to przeglądam nie chyba 100 raz i wydaje mi się że wszystko jest ok ;/

Bo gdy wykonuje zapytania:
  1. $data = Doctrine_Query::create()->from('Model_User u')->select('u.*')
  2. ->fetchArray();

lub
  1. $data = Doctrine_Query::create()->from('Model_UsersDetail d')->select('d.*')
  2. ->fetchArray();


to otrzymuje poprawne wyniki, jednak gdy dodam:
->leftJoin('u.Model_UsersDetail d ON d.Users_id=u.id')
to wszystko się sypie ;/

Proszę pomóżcie.
Go to the top of the page
+Quote Post
Daniel_K
post 11.09.2011, 18:34:15
Post #4





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 25.11.2010

Ostrzeżenie: (0%)
-----


Witam, mam identyczny problem... toffiak - nalazłeś może jakieś rozwiązanie? Bo sprawdzałem już wszystko i nadal Doctrine_Table_Exception: Unknown relation alias ...
Go to the top of the page
+Quote Post
pain3hp
post 14.09.2011, 19:40:10
Post #5





Grupa: Zarejestrowani
Postów: 87
Pomógł: 2
Dołączył: 23.01.2010

Ostrzeżenie: (0%)
-----


myślę że trzeba ręcznie zrobić relacje w klasach które są zmapowane, jednak nie jestem pewny
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 5.07.2025 - 16:22