我有以下环境
Wamp Version :2.4
Apache版本:2.4.4
PHP版本:5.4.16
Firebird / InterBase支持动态 编译时客户端库版本Firebird API版本25 运行时客户端库版本WI-V6.3.0.26074 Firebird 2.5
PDO PDO驱动程序firebird,mysql,sqlite
启用了Firebird / InterBase的PDO驱动程序,但以下php代码无法正常工作。该事务永远不会回滚。
<?php
require_once 'KLogger.php';
$log = new KLogger ( "log.txt" , KLogger::DEBUG );
try
{
$db = new PDO("firebird:dbname=MY-SERVER:MBOOKS-DB", "sysdba", "masterkey");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $db->beginTransaction();
$log->LogInfo('TRANSACTION ' . $result);
$sql = "UPDATE control SET code = code + 1 WHERE ( company_id = 26 ) AND ( fin_year = '0000' ) AND ( item = 'SAL_ID' )";
$stmt = $db->prepare($sql);
$stmt->execute();
//$db->commit();
$db->rollBack();
$db = null;
}
catch (PDOException $e)
{
$db->rollBack();
$log->LogError($e->getMessage());
}
catch (ClientProtocolException $e)
{
$db->rollBack();
$log->LogError($e->getMessage());
}
catch (IOException $e)
{
$db->rollBack();
$log->LogError($e->getMessage());
}
?>
可能是什么问题?
答案 0 :(得分:1)
您可以检查PDO :: ATTR_AUTOCOMMIT是否为0
$db->setAttribute(PDO::ATTR_AUTOCOMMIT,0);