Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] doctriny many-to-many, sf.1.4
janek9
post
Post #1





Grupa: Zarejestrowani
Postów: 121
Pomógł: 2
Dołączył: 22.03.2009

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


hej

Mam problem z relacja wiele do wielu i nie mam pojecia gdzie mam blad.

Oto moj schema.yml

  1.  
  2. pp_content:
  3. actAs:
  4. Timestampable: ~
  5. columns:
  6. id:
  7. type: integer(4)
  8. primary: true
  9. autoincrement: true
  10. notnull: true
  11. category_id:
  12. type: integer(4)
  13. notnull: true
  14. primary: false
  15. autoincrement: false
  16. title:
  17. type: string(255)
  18. description:
  19. type: string()
  20. type: string(255)
  21. is_visible:
  22. type: boolean
  23. default: 1
  24. notnull: true
  25. relations:
  26. images:
  27. class: pp_image
  28. local: image_id
  29. foreign: content_id
  30. refClass: pp_content_image
  31. foreignAlias: Contents
  32.  
  33. pp_image:
  34. actAs: [Timestampable]
  35. columns:
  36. id:
  37. type: integer(4)
  38. primary: true
  39. autoincrement: true
  40. notnull: true
  41. type: string(255)
  42. is_active:
  43. type: boolean
  44. default: 1
  45. notnull: true
  46. indexes:
  47. is_active_idx:
  48. fields: [is_active]
  49. relations:
  50. contents:
  51. class: pp_content
  52. refClass: pp_content_image
  53. local: content_id
  54. foreign: image_id
  55. foreignAlias: Images
  56.  
  57. pp_content_image:
  58. options:
  59. symfony:
  60. form: true
  61. filter: true
  62. actAs: [Timestampable]
  63. columns:
  64. content_id:
  65. type: integer(4)
  66. notnull: true
  67. primary: true
  68. image_id:
  69. type: integer(4)
  70. notnull: true
  71. primary: true
  72. relations:
  73. pp_content:
  74. local: content_id
  75. onDelete: CASCADE
  76. pp_image:
  77. local: image_id
  78. onDelete: CASCADE
  79.  



problem tego rodzaju, ze jezeli chce dodac w trzeciej tabeli inny obrazek o innym id do tego samego klucza z tabeli pp_content to wyrzuca blad ze powtarzaja sie klucze...

  1.  
  2. SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (`pp`.`pp_content_image`, CONSTRAINT `pp_content_image_content_id_pp_content_id` FOREIGN KEY (`content_id`) REFERENCES `pp_content` (`id`) ON DELETE CASCADE)
  3.  



Pytanie do Was: jak to naprawic?
Co chce osiagnac?: zeby do takich samych kluczy z pp_content mozna bylo przypisywac inne klucze z pp_image..
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:38