Home > Backend Development > PHP Tutorial > Thinkphp implements MySQL read-write separation operation example_PHP tutorial

Thinkphp implements MySQL read-write separation operation example_PHP tutorial

WBOY
Release: 2016-07-13 10:26:08
Original
747 people have browsed it

Compared with other methods to achieve MySQL read-write separation, using the Thinkphp framework to achieve MySQL read-write separation is simple and easy to use. The sample code of its configuration file is as follows:

'DB_TYPE'=> 'mysql',
'DB_DEPLOY_TYPE' => 1, //开打支持多服务器        
'DB_RW_SEPARATE'=>true,//数据库读写否分离
'DB_HOST'=> '192.168.11.101,192.168.11.102', 
'DB_NAME'=>'test',      
'DB_USER'=>'admin',      
'DB_PWD'=>'admin101',    
'DB_PREFIX' => 'fav_',
Copy after login

Note:

1. When using the original sql statement for writing operations, execute is used, and query is used for reading operations.
2. MySQL data master-slave synchronization still relies on the MySQL mechanism, so at this time the delay problem of MySQL master-slave synchronization needs to be optimized . Too long delay time not only affects the business, but also affects the user experience.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824805.htmlTechArticleCompared with other methods to achieve MySQL read-write separation, it is simple and easy to use the Thinkphp framework to achieve MySQL read-write separation. The configuration file example code is as follows: 'DB_TYPE'= 'mysql','DB_DEPLO...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template