Yii2-linux, Mac, PHP connection to SQL Server issues

Source: Internet
Author: User
Tags dsn
We have a project that is developed by different teams. Side with windows+ .net+ sql server 2008, the other side uses linux+ yii(php)+ mysqlDevelopment, now want to use yiiTo 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

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.