Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Symfony Encje
Malinaa
post
Post #1





Grupa: Zarejestrowani
Postów: 578
Pomógł: 6
Dołączył: 21.07.2008

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


Witam, mam kłopot przy tworzeniu encji w Symfony,

Tworzę encje np.

  1. class User implements UserInterface
  2. {
  3. /**
  4.   * @ORM\Id
  5.   * @ORM\GeneratedValue
  6.   * @ORM\Column(type="integer")
  7.   */
  8. private $id;
  9.  
  10. public function getId(): ?int
  11. {
  12. return $this->id;
  13. }
  14. }


a chcę, aby było tak:

1. tabela z prefixem = ok / zrobione
2. klucz - id_user / standardowo generuje id i nie mogę zmienić na id_user bo się wysypuje

  1. class DbmUsers implements UserInterface
  2. {
  3. /**
  4.   * @ORM\Id
  5.   * @ORM\GeneratedValue
  6.   * @ORM\Column(type="integer")
  7.   */
  8. private $id_user;
  9.  
  10. public function getIdUser(): ?int
  11. {
  12. return $this->id_user;
  13. }
  14. }


Wykonuje migracje: php bin/console make:migration
i wyskakuje błąd: Column name `id` referenced for relation from App\Entity\DbmUsers towards App\Entity\DbmUsersProfile does not exist.

Jak zmienić automatycznie wygenerowane id na id_user?

Ten post edytował Malinaa 3.02.2021, 23:03:56
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
LowiczakPL
post
Post #2





Grupa: Zarejestrowani
Postów: 531
Pomógł: 55
Dołączył: 3.01.2016
Skąd: Łowicz

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


Mam wrażenie że zależy Ci na tym id_user bo tak masz w jakiejś gotowej bazie, i potrzebujesz integracji, wystarczy dodać name.

  1. /**
  2.   * @ORM\Id
  3.   * @ORM\GeneratedValue
  4.   * @ORM\Column(type="integer", name="id_user")
  5.   */
  6. private $id;


Jeśli jednak nie to pomiń to id, niech sobie będzie, i dodaj swoje pole id_user

Ten post edytował LowiczakPL 4.02.2021, 09:53:32
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: 25.12.2025 - 17:13