Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SOLVED][Symfony] doctrine - nie jest tworzony zwiazek
wiewiorek
post
Post #1





Grupa: Zarejestrowani
Postów: 247
Pomógł: 11
Dołączył: 5.09.2009

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


Uczę się Symfony2.

Plik Strony.php:
  1. <?php
  2.  
  3. namespace Acme\StronaBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7.  
  8. /**
  9.  * @ORM\Entity
  10.  * @ORM\Table(name="strony")
  11.  */
  12. class Strony
  13. {
  14. /**
  15.   * @ORM\Id
  16.   * @ORM\Column(name="id_strony", type="integer", nullable=false)
  17.   * @ORM\GeneratedValue(strategy="AUTO")
  18.   */
  19. protected $IdStrony;
  20.  
  21. /**
  22.   * @ORM\Column(name="meta_tytul", type="string", length=50, nullable=false)
  23.   */
  24. protected $MetaTytul;
  25.  
  26. }


Plik BlokiStron.php:
  1. <?php
  2.  
  3. namespace Acme\StronaBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6.  
  7.  
  8. /**
  9.  * @ORM\Entity
  10.  * @ORM\Table(name="bloki_stron")
  11.  */
  12. class BlokiStron
  13. {
  14. /**
  15.   * @ORM\Id
  16.   * @ORM\Column(name="id_bloku_strony", type="integer", nullable=false)
  17.   * @ORM\GeneratedValue(strategy="AUTO")
  18.   */
  19. protected $IdBlokuStrony;
  20.  
  21. /**
  22.   * @ORM\Column(name="id_strony", type="integer", nullable=false)
  23.   * @ORM\ManyToOne(targetEntity="Strony")
  24.   * @ORM\JoinColumn(name="id_strony", referencedColumnName="id_strony")
  25.   */
  26. protected $Strona;
  27.  
  28. /**
  29.   * @ORM\Column(name="tytul", type="string", length=50, nullable=false)
  30.   */
  31. protected $Tytul;
  32.  
  33. /**
  34.   * @ORM\Column(name="tresc", type="text", nullable=true)
  35.   */
  36. protected $Tresc;
  37.  
  38. }


Jedna strona może mieć wiele bloków.

Dlaczego po wydaniu komendy php app/console doctrine:schema:update --force
tworzy mi w bazie 2 tabele, ale gdy wchodzę do tabeli bloki_stron - widok relacyjny to nie widzę połączenia między obiema tabelami:
http://imageshack.us/photo/my-images/560/beztytuuhje.jpg/

Co robię źle?

------------------------------------------------------------------------------------------

Dobra, wiem, przyczyną było dodanie przeze mnie do klucza obcego:

  1. @ORM\Column(name="id_strony", type="integer", nullable=false)


Ten post edytował wiewiorek 2.08.2011, 16:25:10
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 Aktualny czas: 21.08.2025 - 11:58