In fact, there is a difference between the two. last_insert_id () can return the ID of the bigint value. However, mysql_insert_id returns Int. If you
The ID of is unsigned Int or bigint. The returned result may be incorrect. Instead of last_insert_id.
Some friends still return 0 and do not know what is going on. In fact, last_insert_id () returns the auto_increment ID.
If the table structure is not set, auto_increment cannot be returned.
Some still return 0. Check whether the insert delay function is used. In this case, no immediate id value is returned.
Many people prefer to use select max (ID)... to replace this last_insert_id. In fact, select max (ID) is non-thread-safe and likely,
When new data is inserted in other threads, you cannot find the id you inserted last time. The last_insert_id corresponds to a MySQL connect, that is
It corresponds to your current thread and will not be disturbed by other threads. If some strange errors occur in your database, for example, the information of Data A is to be updated,
Result B data is updated, which is sometimes correct or incorrect. When there are many people, the data is very incorrect. Check whether select max (ID) is used)