How is the csdn id generated?

Source: Internet
Author: User
How is the csdn id generated? A csdn id u012365644 is generated during third-party login.

How is this ID generated? Absolutely unique?


Reply to discussion (solution)

You can consider the automatic growth of IDs in the database.

In theory, it is absolutely unique. the generated method should be auto-increment (the numbering rules are generally customized)

You can consider the automatic growth of IDs in the database.

Oh, I thought so too!

The user table has an account field, which is unique!
When a third-party account is logged on, it will generate a random account substr ('u'. $ uid. uniqid (rand (),), but how can this $ uid be obtained?


You can consider the automatic growth of IDs in the database.

Oh, I thought so too!

The user table has an account field, which is unique!
When a third-party account is logged on, it will generate a random account substr ('u'. $ uid. uniqid (rand (),), but how can this $ uid be obtained?

Third-party login, the first time there will be information stored locally, it is necessary to add a user record



You can consider the automatic growth of IDs in the database.

Oh, I thought so too!

The user table has an account field, which is unique!
When a third-party account is logged on, it will generate a random account substr ('u'. $ uid. uniqid (rand (),), but how can this $ uid be obtained?

Third-party login, the first time there will be information stored locally, it is necessary to add a user record

I am like this:
1. one user table and one user_platform third-party account binding table
2. the user_platform table contains the id (auto-increment), uid (corresponding to the user uid in the user table), type (third-party logo such as qq), and openid (unique id returned by a third party)
3. when a third-party account is logged on for the first time, it will first create an account in the user table. after the account is created successfully, it will write the binding record in the user_platform table, that is, record the newly created user uid and openid

It is in the same order. Therefore, when creating a new user account, I need to first get the uid! This is my idea. How did you do this? the first time I got a third-party login?

I got this for the first time. I don't know if the idea is correct.

I cannot change the bad ID.

In theory, it is absolutely unique. the generated method should be auto-increment (the numbering rules are generally customized)
I am like this:
1. one user table and one user_platform third-party account binding table
2. the user_platform table contains the id (auto-increment), uid (corresponding to the user uid in the user table), type (third-party logo such as qq), and openid (unique id returned by a third party)
3. when a third-party account is logged on for the first time, it will first create an account in the user table. after the account is created successfully, it will write the binding record in the user_platform table, that is, record the newly created user uid and openid

Because of the order, when creating a new user account, I need to get the uid first! This is my idea. How did you do it? for the first time, I got a third-party login.

Mysql has automatically increased fields to ensure uniqueness

It should be an auto-increment function, not an ID column.

Mysql has automatically increased fields to ensure uniqueness
But when inserting data, how do I know how to self-increment uid?


Mysql has automatically increased fields to ensure uniqueness
But when inserting data, how do I know how to self-increment uid?
The data is successfully inserted, and the current auto-increment id is returned.



Mysql has automatically increased fields to ensure uniqueness
But when inserting data, how do I know how to self-increment uid?
The data is successfully inserted, and the current auto-increment id is returned.

If the data is inserted successfully, no id is required! When inserting a record, how can I ensure that the generated account field is unique (uid auto-increment )?

Because the uid is auto-incrementing, you want to use the uid + string to ensure that the account generated is unique.

If you cannot get the auto-incrementing uid in this way, you have to write another update statement!

No auto-increment, because CSDN must have implemented the user's sub-Database. in this way, multiple databases have the same uid, and their uid should be random, it's just that this random one is complicated.

No auto-increment, because CSDN must have implemented the user's sub-Database. in this way, multiple databases have the same uid, and their uid should be random, it's just that this random one is complicated.

Oh, tks

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.