PHP CI framework even SQL Server

Source: Internet
Author: User
Tags microsoft odbc driver for sql server

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

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.