mbomb007
mbomb007

Reputation: 4251

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?

Upvotes: 0

Views: 1090

Answers (1)

Mike Foxtech
Mike Foxtech

Reputation: 1651

The best solution here is to create account on the db server with readonly permissions, and connect using that.

Upvotes: 3

Related Questions