MYSQL inserts entries for missing identifiers (Auto Increment)

I am a fairly new php programmer and can't figure out where I am going wrong by inserting records into my MySQL database:

My script test (for training purposes) calls the eBay API and loads the requested information into the MySQL database, but I seem to get a problem with missing script identifiers in Auto Increment. From what I read here, it is usually when the entries were deleted, but this does not apply to me, since none of them have been deleted, and the spaces are getting bigger and bigger.

My question is: is there anything else that can make the identifier skip random numbers?

Example database: The number runs from 1-21 is just fine, but then it goes: 28,43,51,55,58 I checked, and next to it should be 59:

show create table 'tbl' 
+4
source share
2 answers

Is your code used with transactions? If you roll back the transaction that is inserted into this table, it does not roll back the identifier counter, even if the transaction is rolled back.

See this question: A MySQL table with a primary identifier of AUTO_INCREMENT does not free the number after the rollback .

+4
source

I kind of guess how the code will look, since I'm already working with PayPal APIs, but here's a way to let autoload do this.

This is what my INSERT command looks like and it always works. But providing some code will definitely help.

 "INSERT INTO `table` (auto_increment_id, field1, field2, field3) VALUES ('','$field1','$field2','$field3')"; 

If you leave the first () empty and just put the values ​​after VALUES, you should go with each field, but as I showed you, you say which field should get which value.

You can use SQLite to connect to the database. They are called database browsers.

0
source

Source: https://habr.com/ru/post/1393798/


All Articles