简体   繁体   English

与PDO DBLIB的SQL Server的只读连接

[英]Read-only connection to SQL Server with PDO DBLIB

Is it possible to create a read-only connection using PDO dblib , or set an attribute with a similar effect? 是否可以使用PDO dblib创建只读连接,或者设置具有类似效果的属性?

$connection = new PDO("dblib:host={$info['host']};dbname={$info['database']}", $info['username'], $info['password']);
$connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
return $connection;

If not, is there some other PDO driver that would be able to do this that can connect to FreeTDS? 如果不是,是否有其他PDO驱动程序可以执行此操作以连接到FreeTDS?

最好的解决方案是在具有只读权限的数据库服务器上创建帐户,然后使用该帐户进行连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM