【发布时间】:2011-02-09 20:50:06
【问题描述】:
我在 Symfony 中有一个这样的数据库模式:
Persona:
actAs: { Timestampable: ~ }
columns:
primer_nombre: { type: string(255), notnull: true }
segundo_nombre: { type: string(255) }
apellido: { type: string(255), notnull: true }
rut: { type: string(255) }
email: { type: string(255) }
email2: { type: string(255) }
direccion: { type: string(400) }
ciudad: { type: string(255) }
region: { type: string(255) }
pais: { type: string(255) }
telefono: { type: string(255) }
telefono2: { type: string(255) }
fecha_nacimiento: { type: date }
Alumno:
inheritance:
type: concrete
extends: Persona
columns:
comentario: { type: string(255) }
estado_pago: { type: string(255) }
Alumno_Beca:
columns:
persona_id: { type: integer, primary: true }
beca_id: { type: integer, primary: true }
relations:
Alumno: { onDelete: CASCADE, local: persona_id, foreign: id }
Beca: { onDelete: CASCADE, local: beca_id, foreign: id }
Beca:
columns:
nombre: { type: string(255) }
monto: { type: double }
porcentaje: { type: double }
descripcion: { type: string(5000) }
如您所见,“alumno”从“persona”继承而来。现在我正在尝试为这两个表创建固定装置,但我无法让 Doctrine 加载它们。它给了我这个错误:
SQLSTATE[23000]:完整性约束 违规:1452 无法添加或更新 子行:外键约束 失败(
eat/alumno__beca,约束alumno__beca_persona_id_alumno_id外键 (persona_id) 参考alumno(id) 删除级联)
有人知道如何为从另一个表继承的表编写夹具吗?
谢谢!
【问题讨论】:
标签: php symfony1 doctrine symfony-1.4 doctrine-inheritance