SQLSTATE[23000]:完整性约束违反:1452


SQLSTATE[23000]: Integrity constraint violation: 1452

我的数据库有问题。当我创建一个帖子并选择类别时,我读到:

SQLSTATE[23000]: Integrity constraint violation: 1452不能添加或更新子行:a foreign key constraint fails (apka . c .)post,约束post_kategoria_kategorie_name外键(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

我想在我的表单中选择帖子类别,例如体育,音乐,互联网。我该如何解决这个问题?谢谢你的帮助!

错误相当明显:)

检查服务器错误代码和消息MYSQL知道返回的错误类型

MySql 5.7 docs: https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html#error_er_no_referenced_row_2

好运