PHP operation MySQL Database simple sub-table principle-with detailed steps

Source: Internet
Author: User
 Query ("$sql");//}//Create a new ID storage table, in fact, there is no need to call ID, if the business volume of large by month day also line, by increment also line. CREATE TABLE ' Test '. ' create_id ' (' ID ' BIGINT () not NULL auto_increment PRIMARY KEY) ENGINE = myisam;//Create a new general table, there is no need Own experience (later use to paging, statistics when the direct call on the line, the speed of the query is very fast, if you do not want this table, it is used when the union query: put all the table name into the array, and then foreach in the Assembly of SQL. Union. So it's better to start with a good time.//CREATE TABLE ' article_total ' (//' ID ' bigint () not null,//' subject ' varchar ($) Not null,//' Co Ntent ' text not null,//PRIMARY KEY (' id ')//) Engine=mrg_myisam DEFAULT Charset=utf8 union= (' article_0 ', ' article_1 ', ' AR Ticle_2 ', ' article_3 ');//Query OK, 0 rows affectedfunction get_ai_id () {global $mysqli; $mysqli->query (' INSERT INTO CREATE_ID (ID) VALUES ("") ');Returns the insertion ID value of return mysqli_insert_id ($MYSQLI);} function new_article () {global $mysqli; echo $id =get_ai_id (); Echo $table _name=get_table_name ($id); $sql = "INSERT INTO {$ TABLE_NAME} (Id,subject,content) VALUES (' {$id} ', ' title ', ' content '), "Echo $sql; $mysqli->query ($sql);} function Get_table_name ($id) {return ' Article_ '. Intval ($id)%10;} New_article ();

The above describes the PHP operation MySQL database simple sub-table principle-with detailed steps, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.