Hi there,
I have problem with PDO with
dblib library on Linux CentOS 6.7. When I try to access MS SQL Server 2005 database on Windows Server 2003 I'm getting this error:
Code:
A PHP Error was encountered
Severity: Warning
Message: PDO::__construct(): SQLSTATE[IM001]: Driver does not support this function: driver does not support setting attributes
Filename: pdo/pdo_driver.php
I understand this error message but I don't know what attributes PDO doesn't support? My DB connection settings are:
Code:
$db['winserver'] = array(
'dsn' => 'dblib:host=MSSQL;Database=MyDatabase',
'hostname' => 'MSSQL',
'username' => 'DOMAIN\MyUsername',
'password' => 'MyPassword',
'database' => 'MyDatabase',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I tried to remove some attributes (like 'charset') but the error still remain. Besides that query successfully return results.
I tested conection and query without CodeIgniter and I have no problem:
Code:
try {
$db = new PDO("dblib:host=MSSQL;dbname=MyDatabase", "DOMAIN\MyUsername", "MyPassword");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "SELECT name FROM sys.databases";
$rows = $db->query($query);
$data = $rows->fetchAll(PDO::FETCH_ASSOC);
echo '<pre>'.print_r($data, 1).'</pre>';
} catch(PDOException $e) {
echo '<pre>'.print_r($e, 1).'</pre>';
}
I think that the problem is in PDO class but I can't find the solution. Any advice are appreciated.