thinkphp implementation of MySQL read-write separation operation Example _php instance

Source: Internet
Author: User

Compared to other methods to achieve MySQL's read and write separation, the use of thinkphp framework to achieve MySQL read and write separation is simple and easy-to-use, the configuration file sample code is as follows:

' Db_type ' => ' mysql ',
' Db_deploy_type ' => 1,//fight to support multiple server        
' db_rw_separate ' =>true,//database read/write no separation
' db_ HOST ' => ' 192.168.11.101,192.168.11.102 ', 
' db_name ' => ' test ',      
' db_user ' => ' admin ',      
' db_pwd ' = > ' admin101 ',    
' db_prefix ' => ' fav_ ',

Precautions:

1, when the use of the original ecological SQL statements to write operations, to use execute, read operation to use Query.
2, MySQL data master-slave synchronization or rely on the mechanism of MySQL to achieve, so this time the MySQL master-slave synchronization problem is the need to optimize the delay time is too long not only affect the business, but also affect the user experience.

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.