It is K of the Sapporo office.
Traditionally, the creation of a server system (LAMP environment) was focused on the development of its own framework, but in recent years more and more open source frameworks are being used.
In-house framework is not bad, but if it is an open source framework, I think whether it is easy to take over when operations are taken over from another company, or if you are developing in reverse and handling operations to another company.
So, I'd like to write a Tips of DB that is not careful though it is necessary for FuelPHP that I heard that this time it is getting widely used in social games and other developments.
* For details on what kind of thighs FuelPHP is, refer to the Japanese document.
(FuelPHP Japanese Document)http://fuelphp.jp/
■ Environment created this time
This time, we conducted the verification in the following environment.
Fuel PHP 1.7.3
Although it is called vacant internal examination environment, PHP version is a bit old, but FuelPHP is supporting it.
By the way, the latest release version of FuelPHP is 1.8, and it also supports PHP 7!
I would like to upload any reports there as well.
■ Support for horizontal partitioning of DB table
Horizontal partitioning of database tables is an effective method for load balancing in social games.
However, the horizontal division corresponding to FuelPHP unexpectedly has no information, and it is to be fumbled to make it.
Although FuelPHP has the function of separating the DB itself into master and slave, the processing in the case of horizontally dispersing the table is not taken into consideration and good samples can not be found.
Therefore, we created a model that extends the existing ORM model, and decided to select a table according to conditions.
For each process and child model class, this extension model is inherited and used. (This is an ordinary procedure ..)
In this mechanism, we did the following things.
· Create a connenction that overrides the connection class,
Among them, the table is selected based on the division rule.
· Prepare class for inheritance not to divide for divided table,
Make division setting.
· Individual table classes inherit the above inheritance class and do various things.
Writing it makes me feel a little complicated, but it will be almost as follows.
For example, if you find it, it actually means that it is a mechanism to update its own class in Query :: forge, so this is fine.
When class is automatically generated with Scaffold etc., it needs to be rewritten.
In our company, we prepare a table with distributed destinations and access it from a table obtained by each user (in _ 0 etc.). I think that this area is part of the design.
■ Tramp stuff
Fuel PHP configuration file config was described as being copied from core and rewritten, the one after rewriting will be adopted, but
Under the environment other than Development, we found that the config under the core will live.
Therefore, in the configuration file that I copied this time, I set up with mysqli, but as soon as I changed the environment to production, it is an error! !
As a result of examination, it was an error because core's config default was pdo.
Since FuelPHP frequently rewritten the core itself, it seems necessary to be careful.
I felt that FuelPHP is easy to use and a relaxed framework, but since it also requires some reading ability, I thought it would be better to customize and use it well.
In the future, I would like to touch various things as well as FuelPHP.