<?php namespace App\Model\Database; class Config { public $dsn; public $user; public $password; /** * @var string 分库分表后得到的数据库名 */ public $dbname; /** * @var string 分库分表后得到的表名 */ public $table; /** * @var array MySQL 配置数组 */ private static $config; /** * @var string 配置文件路径 */ private static $configFile = 'mysql.php';
This is a very easy-to-use PHP class for MySQL sub-database and table. Friends who need it can download and use it. More exciting things can be found on the PHP Chinese website.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
11 Mar 2017
Table sharding is a good way to spread the pressure on the database. The most straightforward meaning of table partitioning is to divide a table structure into multiple tables, and then they can be placed in the same library or in different libraries. Of course, you first need to know under what circumstances you need to divide the table. Personally, I think that when the number of records in a single table reaches millions to tens of millions, it is necessary to use sub-tables. 1. Classification of sub-tables 1> Vertical sub-table artificially divides the content that could be in the same table into multiple tables. (The so-called original means that according to the requirements of the third paradigm of relational database, they should be in the same table.) Reason for splitting tables: According to
24 Jul 2018
MySQL database sub-database sub-table solution, once the database is too large, especially when writes are too frequent and it is difficult to be supported by one host, we will still face expansion bottlenecks. At this time, we must find other technical means to solve this bottleneck, which is the bad data segmentation technology we will introduce in this chapter.
03 Jun 2023
1. Why do we need to separate databases and tables? The evolution of the database architecture. In the beginning, most projects used a single-machine database. As the server traffic became larger and larger, we faced more and more requests. We separated the reading and writing of the database and used Multiple slave database copies (Slave) are responsible for reading, and the master database (Master) is responsible for writing. The master and slave realize data synchronization and update through master-slave replication to keep the data consistent. The slave database can be expanded horizontally, so more read requests are not a problem. But when the user level increases and write requests become more and more, how to ensure that the database load is sufficient? Adding a Master cannot solve the problem because the data needs to be consistent and the write operation requires synchronization between the two masters, which is equivalent to duplication.
29 Jul 2016
: PHP sub-database and sub-table hash algorithm: Copy the code code as follows: // Sub-database and sub-table algorithm function calc_hash_db($u, $s = 4) { $h = sprintf("%u", crc32($u)); $h1 = intval(fmod($h, $s)); return $h1; } for($i=1;$i<100;$i++) { echo calc_hash_db($i); echo "<br>"; } f
23 May 2023
PHP is a commonly used programming language used to develop web applications. In modern web applications, data processing is a very important part. With the increasing use of data in web applications, data sharding and table sharding have become one of the basic technologies for data processing. In PHP applications, data sharding and table sharding are also a very important topic. Below we will introduce in detail the importance and implementation methods of data sharding and table sharding in PHP. 1. The importance of data sub-database and table sub-database There are two main methods of data sub-database and sub-table.
21 Jul 2016
PHP sub-database and table hash algorithm. Copy the code as follows: //Sub-database and sub-table algorithm function calc_hash_db($u, $s = 4) { $h = sprintf("%u", crc32($u)); $h1 = intval(fmod($h , $s)); return $h1; } for($i=1;$i100;$i++) {
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images