Linux MSSQL PDO, you need special driver
Closed this issue · 3 comments
If you want to connect to MSSQL with PDO and this means combination of FREETDS and PDO_DBLIB on your client server side you need special dblib driver.
There is no real need for special driver, I'm using FreeTDS and PDO_DBLIB on my develop machine with Sqlsrv driver class. Just tell Nette to use it in your config.neon like this:
database:
dsn: 'dblib:host=*****;dbname=*****;charset=UTF-8;'
user: *****
password: *****
options:
driverClass: Nette\Database\Drivers\SqlsrvDriver
lazy: yes
Luckily for us who tries using Unix and MS services together, this solution is just temporarily. Microsoft is currently working on native Linux sqlsrv and pdo_sqlsrv drivers 😄
See microsoft/msphpsql#43 for info.
There is no release date yet, but hopefully it will be soon (or at least before they release their SQL Server for linux in mid 2017).
IMHO this is not issue, this sould be in documentation.
i had also problem in constructor with this query
$this->version = $connection->getPdo()->getAttribute(\PDO::ATTR_SERVER_VERSION);
my combination of linux, pdo and freetds was unable to run this query, pdo had no attributes in this combination
my solution:
$this->version = $connection->getPdo()->query("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR)")->fetchColumn(0);