(mysql, php) How to get auto_increment field value before inserting data?

前端 未结 8 785
挽巷
挽巷 2020-11-29 11:10

I\'m uploading image file to storage server. Before uploading I should compose filename, which contains AUTOINCREMENT VALUE in it (for example, 12345_filename.jpg).

8条回答
  •  半阙折子戏
    2020-11-29 11:59

    @Pascal Martin makes a good point. In cases like this, I personally like to add another ID column, containing a random, 16-digit ID (which will also be the "public" ID in web apps and on web sites for security reasons). This random ID you can set beforehand in your application, work with it, and then set when the record is actually created.

提交回复
热议问题