0
我的数据库有问题。当我创建一个职位并选择类别,我读:SQLSTATE [23000]:完整性约束违规:1452
SQLSTATE [23000]:完整性约束违规:1452不能添加或更新子行,外键约束失败(
apka
post
,约束post_kategoria_kategorie_name
。 FOREIGN KEY(kategoria
)参考文献kategorie
(name
)ON DELETE CASCADE)。
这是我的schema.yml:
Kategorie:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
Post:
actAs: { Timestampable: ~ }
columns:
user_id: { type: string(155), notnull: true }
kategoria: { type: string(255) }
tresc_postu: { type: string(4000), notnull: true }
publiczny: { type: boolean, notnull: true, default: 1 }
relations:
Kategorie: { onDelete: CASCADE, local: kategoria, foreign: name, foreignAlias: Category }
和数据
# categories.yml
Kategorie:
sport:
name: Sport
muzyka:
name: Muzyka
internet:
name: Internet
我要选择我的形式发布分类,恩。体育,Muzyka,互联网。我怎么解决这个问题? 谢谢你的帮助!
价值,你是插入可能无法在主表中通过它给外键约束失败错误 –
所以..我该怎么办?它将如何正确工作? – Daniorocket
提供适当的值或在插入到表中之前检查它的值是否在主表中可用,如果可用,则罚款否则将其插入到主表中然后在第二个表中 –