Mysql-php randomly comes up with a combination of numbers and letters that loops into the database and then determines what to do if the database exists and then loops back into the database.

Source: Internet
Author: User

PHP a random code, according to the ID inserted into the database, and then determine if the database already exists in the random code and then randomly inserted into the database

Reply content:

PHP a random code, according to the ID inserted into the database, and then determine if the database already exists in the random code and then randomly inserted into the database

while (true) {    // 生成随机数    // 判断数据库中是否存在    if ($noFount) { // 如果不存在        // 插入数据库        break;    }}

The field defines a unique key, inserts it using a transaction loop, inserts a successful commit, and jumps out of the loop.

1. You first find out all the contents of the DB.
2. In_array again () until false
3. Inserting data

  • Related Article

    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.