gpt4 book ai didi

PHP回滚方法失败

转载 作者:行者123 更新时间:2023-11-29 22:23:38 25 4
gpt4 key购买 nike

我已经尝试过这段代码,不幸的是回滚方法失败了!提前致谢!!

$bash = new mysqli('localhost', 'root', '','dbastegoi');
$bash->autocommit(FALSE);

echo 'timologio';
$r =$bash->query("INSERT INTO tbparastatika (strArithmos, fkERGO, strPROMITH, sngCOST, intTYPOS, intDRASH) VALUES ('1','1001','123123123',800138,1,1)");
//ΕΙΣΑΓΩΓΗ ΤΙΜΟΛΟΓΙΟΥ
$i = $bash->insert_id;
ECHO PHP_EOL;
echo 'dapanh';
try {
$r =$bash->query("INSERT INTO tbdapanes_stegash (idPARASTATnIKO, sngCOST, fkDIAMERISMA, intMONTH) VALUES ($i,100,1,1)");
echo $r;
} catch (Exception $e) {
echo 'error2';
}

$bash->commit();
$bash->rollback();

//$SYNDESH->commit();
//$SYNDESH->rollback();
$bash->close();

最佳答案

您不能先提交然后回滚。如果查询运行没有错误,则必须进行提交;如果出现错误,则必须进行回滚:

try {
$r =$bash->query("INSERT INTO tbdapanes_stegash (idPARASTATnIKO, sngCOST, fkDIAMERISMA, intMONTH) VALUES ($i,100,1,1)");
echo $r;
$bash->commit();
} catch (Exception $e) {
echo 'error2';
$bash->rollback();
}

关于PHP回滚方法失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30474238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com