Plik Strony.php:
<?php namespace Acme\StronaBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="strony") */ class Strony { /** * @ORM\Id * @ORM\Column(name="id_strony", type="integer", nullable=false) * @ORM\GeneratedValue(strategy="AUTO") */ protected $IdStrony; /** * @ORM\Column(name="meta_tytul", type="string", length=50, nullable=false) */ protected $MetaTytul; }
Plik BlokiStron.php:
<?php namespace Acme\StronaBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="bloki_stron") */ class BlokiStron { /** * @ORM\Id * @ORM\Column(name="id_bloku_strony", type="integer", nullable=false) * @ORM\GeneratedValue(strategy="AUTO") */ protected $IdBlokuStrony; /** * @ORM\Column(name="id_strony", type="integer", nullable=false) * @ORM\ManyToOne(targetEntity="Strony") * @ORM\JoinColumn(name="id_strony", referencedColumnName="id_strony") */ protected $Strona; /** * @ORM\Column(name="tytul", type="string", length=50, nullable=false) */ protected $Tytul; /** * @ORM\Column(name="tresc", type="text", nullable=true) */ protected $Tresc; }
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:
@ORM\Column(name="id_strony", type="integer", nullable=false)