I’m quite a new php programmer and cannot seem to figure out where I’m going wrong with inserting records into my MySQL database:
My test script (for learning purpose) calls the eBay API and downloads the requested information into the MySQL database but I seem to be getting the issue of the script skipping IDs on the Auto Increment. From what I have been reading here this is normally when records have been deleted but this is not the case for me as none have been deleted and the gaps get bigger and bigger.
My question is: Is there something else that can cause the id to skip random numbers?
Database example:
Number run from 1-21 just fine but then goes: 28,43,51,55,58
I have checked and next to be added should be 59:
show create table 'tbl'
2
Answers
Is your code using transactions? If you rollback a transaction that inserts into that table it doesn’t roll back the identity counter even if the transaction gets rolled back.
See this question: MySQL table with AUTO_INCREMENT primary id does not release the number after a rollback.
I am kind of guessing what the code will look like, since I am too working with PayPal APIs now, but here is a way to let the auto_increment do it’s job
This is how my INSERT command looks like and its been always working. But providing some code will definitely help.
To connect to live database you can use SQLite. They are called database browsers.