We have a project that is developed by different teams. Side with
windows
+
.net
+
sql server 2008
, the other side uses
linux
+
yii(php)
+
mysql
Development, now want to use
yii
To connect
sql server
, the system for the development environment is
osx
, how to solve the connection problem?
Reply content:
We have a project that is developed by different teams. One side with + +, the windows
.net
sql server 2008
Other side with linux
+ + yii(php)
mysql
development, now want yii
to use to connect sql server
, the development environment of the system is osx
, how to solve the problem of the connection?
Http://www.yiiframework.com/doc/guide/1.1/en/database.dao#establishing ...
And link MySQL is the same.
If you go to connect to SQL Server, you can change the DSN configuration.
$connection=new CDbConnection('mssql:host=localhost;dbname=testdb',$username,$password);
If the host is not on a single machine, the next Host=sql_server_host
Find some answers and make a note of some problems.
http://php.net/manual/zh/pdo.drivers.php
FreeTDS and Pdo_dblib are currently being solved, but there is a problem with coding. Yii is used with GBK on Utf-8,sql server.
OSX configuration below, UTF8 put below will error, do not know what reason.
'api' => [ 'class' => 'yii\db\Connection', 'dsn' => 'dblib:host=x.x.x.x;dbname=dbname;charset=utf8', 'username' => 'username', 'password' => 'password', //'charset' => 'utf8', ],
Ubuntu is configured as follows, UTF8, the program is running normally, but writing to SQL Server is garbled.
'api' => [ 'class' => 'yii\db\Connection', 'dsn' => 'dblib:host=x.x.x.x;dbname=dbname;charset=utf8', 'username' => 'username', 'password' => 'password', //'charset' => 'utf8', ],
The coding problem has been resolved, see here: http://segmentfault.com/q/1010000002661362
After studying the problem, I know it. Unix/linux connect to SQL Server in many ways, such as FreeTDS + UnixODBC (IODBC).
PHP PDO can support, regardless of which database, is nothing more than the database drive and Database Manager connection problem.
PHP PDO Link: http://php.net/manual/zh/pdo.drivers.php