MSSQL (dblib): Driver does not support this function

Hi all

I would like to connect to a remote MS-SQL Server with the pdo_dblib driver (freetds) on CentOS 5.5.

After some minor problems with the OS configuration, I finally got the connection working with a manual connect with

$connection=new CDbConnection($dsn,$username,$password); 

Unfortunately, when using the Yii database component (as specified in config/main.php) I get the following error:

when I try to retrieve the connection with this code in my Controller:

$connection = Yii::app()->db;

My db settings are as follows:


	'connectionString' => 'dblib:host=SERVER_IP;dbname=DB',

	'emulatePrepare' => false,

	'username' => 'USER',

	'password' => 'PASS',

	'charset' => 'utf8',


Any ideas why this is happening?

I would really like to use the “shared” connection instead of create a new one every time :)

Best regards


take a look here

Hi Gustavo. In my case, the PDO driver is installed and does work if I connect manually with

$connection=new CDbConnection($dsn,$username,$password);


But not when using

$connection = Yii::app()->db;

together with the db settings in config/main.php.

true, I read it in a hurry

the problem is that you can’t set attributes to this driver

'charset' => 'utf8','emulatePrepare' => false,

I’m not sure tho which attributes you can or cannot set, as I haven’t used this driver yet

Yeah! You were right: it was because of charset and emulatePrepare. Thanks alot :)

I think you can set the charset in freetds.conf with "client charset = UTF-8".

Gustavo, Thanks. It works

Form me removing only ‘emulatePrepare’ => false,’ was enough

Gustavo you’re king !

So Thank`s, My I ask you to describe emulatePrepare in Yii db?