Home > php教程 > php手册 > pdo_dblib extension for Linux system ThinkPHP5 to link to MsSQL database

pdo_dblib extension for Linux system ThinkPHP5 to link to MsSQL database

WBOY
Release: 2016-10-09 08:32:17
Original
2183 people have browsed it

LinUX (centOS6.8) system ThinkPHP5 links the pdo_dblib extension of the MsSQL database
The first step is to download and install freetds-current.tar.gz. The download address is as follows
ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gz
1.1 Download, unzip and enter the folder (in fact, you can also unzip and then upload to the linux server) wget ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gztar zxvf freetds-current.tar.gzcd freetds-stable*The path after decompression may not be correct if you look at it
1.2 Execute ./configure./configure --prefix=/usr/local/freetds --with-tdsver=7.1 --enable-msdblib1.3 Execute make installmake && make installThe second step is to install PHP and install pdo_dblib Extension
2.1 Enter the PHP source file directory you installed. If you cannot find it, find the PHP file of the same version, decompress it and upload it to the Linux server. I will take this path /root/scr/php/ext/pdo_dblib as an examplecd /root/scr/ php/ext/pdo_dblib2.2 Execute phpize If your php is not installed in the /usr/local path, you need to change it to your own php path/usr/local/php/bin/phpizeFor example, my php installation path is /www/wdlinux/apache_php-5.6.21/ will execute /www/wdlinux/apache_php-5.6.21/bin/phpize

2.3 Execute ./configure Same as above. If your php is not installed in the /usr/local path, you need to change it to your own php path./configure --with-php-config=/usr/local/php/bin/php- config --with-pdo-dblib=/usr/local/freetdsFor example, my PHP installation path is /www/wdlinux/apache_php-5.6.21/ then./configure --with-php-config=/www/ wdlinux/apache_php-5.6.21/bin/php-config --with-pdo-dblib=/usr/local/freetds

2.4 Execute make installmake && make installThe third step is to modify php.ini. Same as above. If your php is not installed in the /usr/local path, you need to modify it to your own php path
For example, my php installation path is /www/wdlinux/apache_php-5.6.21/
3.1 Verify the path of the compiled file
Go into /usr/local/php/lib/php/extensions and check if there are mssql.so and pdo_dblib.so files in it or in the lower-level directories
If it exists, it means the compilation is successful
3.2 Modify php.inivi /usr/local/php/etc/php.ini and add the following code at the bottom and save the vi modification (press i to enter the editing mode first, after the addition is successful, press the Esc key to exit the editing mode and then enter :wq and press Enter to save)extension="/usr/local/php/lib/php/extensions/mssql.so"<br> extension="/usr/local/php/lib/php/extensions/pdo_dblib.so"Different servers may have different codes, and my PHP installation and compilation paths are differentextension="/www/wdlinux/apache_php- 5.6.21/lib/php/extensions/no-debug-non-zts-20131226/mssql.so"<br> extension="/www/wdlinux/apache_php-5.6.21/lib/php/extensions/no-debug-non-zts-20131226/pdo_dblib.so"3.3 After everything is done, restart Apache apache. Of course, you can also enter reboot. Restart the serverservice httpd restrat3.4 If you feel uneasy, check the php probe file to see if mssql and pdo_dblib are installed successfully
pdo_dblib extension for Linux system ThinkPHP5 to link to MsSQL database
pdo_dblib extension for Linux system ThinkPHP5 to link to MsSQL database
Step 4 Download the attachment and copy the database driver extension file to the ThinkPHP file
Put the file under /thinkphp/library/think/db in the main program
There are two files, which are placed in the builder and connector folders. The two questions have the same name, both are Dblib.php, but they cannot be confused. Remember
Step 5 Configure the database.php file return [<br> //Database type<br> 'type' => 'dblib',<br> // Server address<br> 'hostname' => '192.168.1.210',<br> // Database name<br> 'database' => 'Mikkle_WeiXin',<br> // Username<br> 'username' => 'sa',<br> //Password<br> 'password' => '123123123123123',<br>//Port<br> 'hostport' => '1433',<br> // Connect to dsn<br> ‘dsn’                                                                                                                                                                                                                                                                                                       //Database connection parameters<br> 'params' => [],<br> //The database encoding defaults to utf8<br> 'charset' => 'utf8',<br> // Database table prefix<br> 'prefix' => 'WeiXin_',<br> // Database debugging mode<br> 'debug' => true,<br> //Database deployment method: 0 centralized (single server), 1 distributed (master-slave server)<br> 'deploy' => 0,<br> // Is the database reading and writing separated? The master-slave method is valid<br> 'rw_separate' => false,<br> //Number of primary servers after separation of reading and writing<br> 'master_num' => 1,<br> //Specify the slave server serial number<br> 'slave_no' => '',<br> // Whether to strictly check whether the field exists<br> 'fields_strict' => true,<br> //Dataset return type array array collection Collection object<br> 'resultset_type' => 'array',<br> // Whether to automatically write the timestamp field<br> 'auto_timestamp' => true,<br> // Do you need to perform SQL performance analysis<br> 'sql_explain' => false,<br> ];<br>Ok and you’re done

Thinkphp5 Pdo_dblib extension.zip pdo_dblib extension for Linux system ThinkPHP5 to link to MsSQL database(3.16 KB Download: 1 time)

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template