Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework][ZF2] Doctrine 2 generowanie Entites z DB
netvalue
post
Post #1





Grupa: Zarejestrowani
Postów: 199
Pomógł: 2
Dołączył: 9.06.2008

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


Cześć

Po przez doctrine-module orm:conver-mapping -from data-base , próbuje wygenerowac Entites ale otrzymuje blad

  1. Table category_product has no primary key.


moje tabel sql:
  1. CREATE TABLE IF NOT EXISTS `category_product` (
  2. `id_category` int(11) NOT NULL,
  3. `id_product` int(11) NOT NULL
  4. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  5.  
  6. CREATE TABLE IF NOT EXISTS `product` (
  7. `id_product` int(11) NOT NULL AUTO_INCREMENT,
  8. `name` varchar(255) CHARACTER SET utf8 NOT NULL,
  9. PRIMARY KEY (`id_product`),
  10. KEY `product_name` (`name`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



Niestety nie moge ustawić primary key w tabeli category_product poniewaz sa tam rekordy np:

id_category | id_product
2 | 3
2 | 4
10| 3


Co moge zrobic w takim przypadku ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
netvalue
post
Post #2





Grupa: Zarejestrowani
Postów: 199
Pomógł: 2
Dołączył: 9.06.2008

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


teraz otrzumje przy generowaniu Entitre:
Table product_params has no primary key.



(IMG:http://s29.postimg.org/iw1tz2akn/Bez_nazwy_1.jpg)

  1. CREATE TABLE IF NOT EXISTS `category` (
  2. `id_category` int(11) NOT NULL,
  3. `name` varchar(255) DEFAULT NULL,
  4. `id_parent` int(11) NOT NULL,
  5. PRIMARY KEY (`id_category`)
  6. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  7.  
  8. -- --------------------------------------------------------
  9.  
  10. --
  11. -- Struktura tabeli dla tabeli `category_product`
  12. --
  13.  
  14. CREATE TABLE IF NOT EXISTS `category_product` (
  15. `id_product` int(11) NOT NULL,
  16. `id_category` int(11) NOT NULL,
  17. PRIMARY KEY (`id_product`,`id_category`),
  18. KEY `fk_product_has_category_category1_idx` (`id_category`),
  19. KEY `fk_product_has_category_product_idx` (`id_product`)
  20. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  21.  
  22. -- --------------------------------------------------------
  23.  
  24. --
  25. -- Struktura tabeli dla tabeli `product`
  26. --
  27.  
  28. CREATE TABLE IF NOT EXISTS `product` (
  29. `id_product` int(11) NOT NULL,
  30. `name` varchar(255) DEFAULT NULL,
  31. PRIMARY KEY (`id_product`)
  32. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  33.  
  34. -- --------------------------------------------------------
  35.  
  36. --
  37. -- Struktura tabeli dla tabeli `product_params`
  38. --
  39.  
  40. CREATE TABLE IF NOT EXISTS `product_params` (
  41. `id_product` int(11) NOT NULL,
  42. `name` varchar(255) DEFAULT NULL,
  43. KEY `fk_product_params_product1_idx` (`id_product`)
  44. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  45.  
  46. --
  47. -- Ograniczenia dla zrzutów tabel
  48. --
  49.  
  50. --
  51. -- Ograniczenia dla tabeli `category_product`
  52. --
  53. ALTER TABLE `category_product`
  54. ADD CONSTRAINT `fk_product_has_category_product` FOREIGN KEY (`id_product`) REFERENCES `product` (`id_product`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  55. ADD CONSTRAINT `fk_product_has_category_category1` FOREIGN KEY (`id_category`) REFERENCES `category` (`id_category`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  56.  
  57. --
  58. -- Ograniczenia dla tabeli `product_params`
  59. --
  60. ALTER TABLE `product_params`
  61. ADD CONSTRAINT `fk_product_params_product1` FOREIGN KEY (`id_product`) REFERENCES `product` (`id_product`) ON DELETE NO ACTION ON UPDATE NO ACTION;


Ten post edytował netvalue 22.08.2014, 09:45: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 - 17:24