hej
Mam problem z relacja wiele do wielu i nie mam pojecia gdzie mam blad.
Oto moj schema.yml
pp_content:
actAs:
Timestampable: ~
columns:
id:
type: integer(4)
primary: true
autoincrement: true
notnull: true
category_id:
type: integer(4)
notnull: true
primary: false
autoincrement: false
title:
type: string(255)
description:
type: string()
type: string(255)
is_visible:
type: boolean
default: 1
notnull: true
relations:
images:
class: pp_image
local: image_id
foreign: content_id
refClass: pp_content_image
foreignAlias: Contents
pp_image:
actAs: [Timestampable]
columns:
id:
type: integer(4)
primary: true
autoincrement: true
notnull: true
type: string(255)
is_active:
type: boolean
default: 1
notnull: true
indexes:
is_active_idx:
fields: [is_active]
relations:
contents:
class: pp_content
refClass: pp_content_image
local: content_id
foreign: image_id
foreignAlias: Images
pp_content_image:
options:
symfony:
form: true
filter: true
actAs: [Timestampable]
columns:
content_id:
type: integer(4)
notnull: true
primary: true
image_id:
type: integer(4)
notnull: true
primary: true
relations:
pp_content:
local: content_id
onDelete: CASCADE
pp_image:
local: image_id
onDelete: CASCADE
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...
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
)
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..