Welcome Guest, Not a member yet? Register   Sign In
pdo error: driver does not support setting attributes

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:

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:
$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:
try {
   $db = new PDO("dblib:host=MSSQL;dbname=MyDatabase", "DOMAIN\MyUsername", "MyPassword");
   $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.

Theme © iAndrew 2016 - Forum software by © MyBB