How PHP is calculated from the UID to insert which database

Source: Internet
Author: User
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
  • 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.