1. Add sqlsrv Extensions for PHP
Go to Microsoft official website https://www.microsoft.com/en-us/download/search PHP,
Click Microsoft Drivers forPHP for SQL Server
Download the latest version of SqlsrvXX.exe (i downloaded SQLSRV32.EXE)
Run the decompression, get a bunch of DLLs, choose the appropriate PHP version of the DLL, put into the php\ext\ directory; (My PHP version is 5.6.3, the selection is Php_sqlsrv_56_ts.dll, 56 is the PHP version of 5.6.x)
Add a line to the php.ini Extension=php_sqlsrv_56_ts.dll
Restart the service, view phpinfo (), if there are sqlsrv entries, prove the extension to install successfully.
And because of SQLSRV3. X.EXE requires additional drivers for Microsoft ODBC Driver 11 (or later), so you need to install Microsoft ODBC Driver 11
Visit https://msdn.microsoft.com/en-us/library/cc296170%28v=sql.105%29.aspx
Find this passage.
Versions 3.2 and 3.1 require Microsoft ODBC Driver one (or higher) for SQL Server. To download the Microsoft ODBC Driver one-for-PHP for SQL Server, Seemicrosoft ODBC Driver one-to-one for SQL Server.
Click Microsoft ODBC Driver for SQL Server.
Download the installation.
ALL COMPLETE!!!!!
Write a test script
$serverName = "xxxxxx"; Servername\instancename$connectioninfo = Array ("Database" = "", "UID" = "xxx", "PWD" = "xxx"); $conn = sqlsrv _connect ($serverName, $connectionInfo), if ($conn) { echo "Connection established.<br/>";} else{ echo "Connection could not being established.<br/>"; Die (Print_r (Sqlsrv_errors (), True));}
2. In CI configuration sqlsrv database configuration (CI 3.0.0 for example)
Static configuration
Open config\database.php Modify, notice dbdriver this item fill sqlsrv;
Dynamic configuration or multiple databases
In the model file, in the constructor (remember to write Parent::__contruct () to inherit the constructor of the parent class) join
$this->another_db = $this->load->database ($config, true); $config can be copied directly from Database.php, true to have a return value.
And then you can fly.
$this->another_db->get ();
$this->another_db->get_where ();
.....
PHP CI framework even SQL Server