由于违反完整性约束,Propel 无法删除

Propel cannot delete due to Integrity constraint violation

我 运行 使用 Propel 1.6.9,之前的开发人员最近更新了文件,因为我在笔记本电脑上生成正确的文件时仍然遇到一些问题。一切顺利,除了在尝试删除某些内容时出现一个问题。

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`db000_app/file_meta`, CONSTRAINT `file_meta_FK_1` FOREIGN KEY (`case_id`) REFERENCES `agency_costs` (`id`))' in /var/www/vhosts/10/154462/webspace/httpdocs/domain/vendor/propel/propel1/runtime/lib/connection/DebugPDOStatement.php:90 

Stack trace: 
#0 /var/www/vhosts/10/154462/webspace/httpdocs/domain/vendor/propel/propel1/runtime/lib/connection/DebugPDOStatement.php(90): PDOStatement->execute(NULL) 
#1 /var/www/vhosts/10/154462/webspace/httpdocs/domain/vendor/propel/propel1/runtime/lib/util/BasePeer.php(145): DebugPDOStatement->execute() 
#2 /var/www/vhosts/10/154462/webspace/httpdocs/domain/vendor/propel/propel1/build/classes/onterechtbetaald/om/BaseAgencyCostsPeer.php(1085): BasePeer::doDelete(Object(AgencyCostsQuery), Object(DebugPDO)) 
#3 [internal function]: BaseAgencyCo in /var/www/vhosts/10/154462/webspace/httpdocs/domain/vendor/propel/propel1/runtime/lib/util/BasePeer.php on line 149

调用删除函数的代码:

$case = AgencyCostsQuery::create()->findPk($_POST["DeleteId"]);

if ($case !== null)
{
  $case->deleteFiles();
  $case->delete();
}

如前所述,这在文件更新之前工作得很好。数据库已更改:已将两列添加到 agency_costs.

关于如何克服这个错误有什么想法吗?

问题是由数据库中的约束定义引起的。 约束设置为限制删除和更新。 将其更改为级联解决了我的问题。