PDOException:“无法为此驱动程序更改自动提交模式" [英] PDOException: "The auto-commit mode cannot be changed for this driver"
本文介绍了PDOException:“无法为此驱动程序更改自动提交模式"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据各种消息来源,我正在尝试使PDO连接到SQL服务器以输入READ UNCOMMITTED(
I'm trying to get PDO connecting to an SQL server to enter READ UNCOMMITTED, according to various sources (https://msdn.microsoft.com/en-us/library/cc296183(v=sql.105).aspx) this is how you do it.
$pdo = new PDO ("sqlsrv:server=$hostname;database=$dbname",$username,$pw,[PDO::SQLSRV_TXN_READ_UNCOMMITTED]);
这将导致PDOException:无法为此驱动程序更改自动提交模式"
This results in a PDOException: "The auto-commit mode cannot be changed for this driver"
推荐答案
使用PDO时,必须使用以下形式:
When you're using PDO, you have to use this form:
$conn = new PDO("sqlsrv:Server=".$hostname.
";Database=".$database.
";TransactionIsolation=".PDO::SQLSRV_TXN_READ_UNCOMMITTED,
$username, $pw);
https://msdn.microsoft.com/en-us/library/ff628167.aspx
这篇关于PDOException:“无法为此驱动程序更改自动提交模式"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文