简体   繁体   中英

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?

$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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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