Yii Framework Forum: MSSQL (dblib): Driver does not support this function - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

MSSQL (dblib): Driver does not support this function Rate Topic: -----

#1 User is offline   ycast 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 02-January 11

Posted 27 July 2011 - 11:25 AM

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:

Quote

CDbConnection failed to open the DB connection: SQLSTATE[IM001]: Driver does not support this function: driver does not support setting attributes

when I try to retrieve the connection with this code in my Controller:
$connection = Yii::app()->db;


My db settings are as follows:
'db'=>array(
	'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
ycast
0

#2 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 27 July 2011 - 11:28 AM

take a look here
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#3 User is offline   ycast 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 02-January 11

Posted 27 July 2011 - 11:57 AM

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.
0

#4 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 27 July 2011 - 12:22 PM

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

--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
1

#5 User is offline   ycast 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 49
  • Joined: 02-January 11

Posted 27 July 2011 - 03:21 PM

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".
0

#6 User is offline   marinovdf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 18-January 13

Posted 18 January 2013 - 03:14 AM

View PostGustavo, on 27 July 2011 - 12:22 PM, said:

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

Gustavo, Thanks. It works
0

#7 User is offline   Blaza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-December 10

Posted 07 February 2013 - 04:29 PM

View PostGustavo, on 27 July 2011 - 12:22 PM, said:

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


Form me removing only 'emulatePrepare' => false,' was enough
0

#8 User is offline   drxy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 12-September 12

Posted 06 July 2013 - 07:33 AM

Gustavo you're king !
0

#9 User is offline   Shahcheraghean 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 478
  • Joined: 12-December 12
  • Location:Mashhad, IRAN

Posted 20 August 2013 - 02:55 AM

View PostGustavo, on 27 July 2011 - 12:22 PM, said:

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

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


So Thank`s, My I ask you to describe emulatePrepare in Yii db?
www.shgn.ir
www.shgn.ir/yii-framework/
yii2.swsco.ir
In a world without any fences or walls,Who needs Gates or Windows!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users