Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][Doctrine-orm] Mapowanie i association-mapping
twojastara
post
Post #1





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


Dokumentacja mówi, że jeśli w klasie Entity dodaję właściwości

np.
  1. /** @Column(type="integer") */
  2. private $id;
  3. /** @Column(length=140) */
  4. private $text;
  5. /** @Column(type="datetime", name="posted_at") */
  6. private $postedAt;

To po wydaniu komendy doctrine:generate:entities i doctrine:schema:update
w bazie powstaną kolumny id, text i postedAt

A czy ten zapis też stworzy kolumnę (panstwa)?
  1. /**
  2. * @ORM\OneToMany(targetEntity="Panstwo", mappedBy="kontynent")
  3. */
  4. protected $panstwa;


Bo dokumentacja mówi że taki zapis
  1. /** @Entity **/
  2. class Product
  3. {
  4. // ...
  5.  
  6. /**
  7.   * @OneToOne(targetEntity="Shipping")
  8.   * @JoinColumn(name="shipping_id", referencedColumnName="id")
  9.   **/
  10. private $shipping;
  11.  
  12. // ...
  13. }
  14.  
  15. /** @Entity **/
  16. class Shipping
  17. {
  18. // ...
  19. }


wygeneruje taki schema
  1. CREATE TABLE Product (
  2. id INT AUTO_INCREMENT NOT NULL,
  3. shipping_id INT DEFAULT NULL,
  4. UNIQUE INDEX UNIQ_6FBC94267FE4B2B (shipping_id),
  5. PRIMARY KEY(id)
  6. ) ENGINE = InnoDB;
  7. CREATE TABLE Shipping (
  8. id INT AUTO_INCREMENT NOT NULL,
  9. PRIMARY KEY(id)
  10. ) ENGINE = InnoDB;
  11. ALTER TABLE Product ADD FOREIGN KEY (shipping_id) REFERENCES Shipping(id);

czyli nie tworzy kolumny `shipping`

Ten post edytował twojastara 5.02.2015, 22:16:13
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 22.08.2025 - 20:37