SQLSTATE [23000]:违反完整性约束:1451无法在PHP和Mysql中删除

时间:2019-07-12 08:10:20

标签: php mysql foreign-keys sql-delete

我的删除功能有一些问题。.可能是一个错误,有时它起作用,有时却没有。

当我删除“整个审核表”时,我试图从三个不同的表中删除。我了解您必须先删除带有外键的那个。但是,Audit_Trans_Photo中有可能没有数据

audit_trans_photoDAO

OperationalError: Failed to get the current sub/segment from the context.
    at Object.contextMissingRuntimeError [as contextMissing]

audit_transactionDAO

public function removeAuditID($auditID) {
        $sql = 'delete ignore from audit_trans_photo where auditID=:auditID';

audit_form

public function remove($auditID) {
        $sql = 'delete from audit_transaction where auditID=:auditID';

删除页面

public function remove($auditID) {
        $sql = 'delete from audit_form where auditID=:auditID';
$passed_array = unserialize($_POST['input_name']);

foreach ($passed_array as $id){
    $dao3 = new Audit_Trans_PhotoDAO();
    $dao3->removeAuditID($id);

    $dao = new Audit_TransactionDAO();
    $dao->remove($id);

    $dao2 = new Audit_FormDAO();
    $dao2->remove($id);
}

0 个答案:

没有答案