How can PHP be computed from the UID to insert which database?
I'm now going to implement a feature:
To calculate the UID of 200w user by calculation rule, how to calculate the table with different insert log, is the table balanced processing?
------Solution--------------------
The UID is usually a number, and the modulo will be
------Solution--------------------
Does this require code?
The value $uid as the UID, $m as the number of log tables
The table name $tbl = ' prefix '. ($uid% $m)
------Solution--------------------
Don't know what the naming rules are for your multiple tables? Is 200W user, randomly assigned log table, or when this user is created, specify which table to put on?
1. If it is random, the best name of the table has a certain rule, such as: log001, log002 ..., log100 like this. Directly with Rand () processing a number out, and then spell the table name;
2. If the user is created, you specify which table to write, it is better to do, in the user login, the table name is written to the session, write the day, directly splicing;
3. If you want to determine according to the user's first character, you can also use Method 2;
------Solution--------------------
You first need to define the good one table, and then
For ($i-0; $i <300; $i + +)
mysql_query ("Carete table log_$i select * FROM table where 1=0");
300 tables are built.
Table name calculation when inserting I have given it in #6