使用ODBC驱动程序将setAttribute设置为PDO? [英] setAttribute to PDO using ODBC Driver?

查看:128
本文介绍了使用ODBC驱动程序将setAttribute设置为PDO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的pdo连接设置一些属性,我正在使用连接到SQL Server的odbc drvier,但是我得到了未知的属性

i am trying to set some attributes to my pdo connection, i am using the odbc drvier that is connecting to SQL Server and i get unknown attribute

$db = new PDO("odbc:Driver={SQL Server};Server=127.0.0.1;Database=my_db;charset=utf8; Uid=my_usser;Pwd=my_pass;");
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
print_r($db->errorinfo());

//It show me: Array ( [0] => 00000 [1] => 0 [2] => Unknown Attribute (setAttribute[0] at (null):0) [3] => IM001 ) 

我想将PDO :: ATTR_EMULATE_PREPARES设置为false coz,我读到这里是使用prepare functiom时停止sql注入的安全方法.

I want to set PDO::ATTR_EMULATE_PREPARES to false coz i read here is a secure way to stop sql injection when using prepare functiom.

推荐答案

无法使用从Linux到MSSQL的准备好的语句.在Windows上部署生产代码并使用PDO SQLSRV驱动程序,或者不使用准备好的语句(这基本上意味着您不能使用Unicode).

It is not possible to use prepared statements from Linux to MSSQL. Deploy your production code on Windows and use PDO SQLSRV driver, or don't use prepared statements (which basically means you can't use Unicode).

这篇关于使用ODBC驱动程序将setAttribute设置为PDO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆