3

I'm working on a small Laravel app to learn the framework. I'm no more than 2 weeks into Laravel and I'm playing around with a meaningless application that I am building for learning purposes only. So if this is normal - please excuse me.

I noticed today, when submitted data from a form into a MySQL database, that the primary ID auto increments by 10, instead of 1. I have never seen this happen before in anything, so my concern is that I've done something wrong, or there is a setting that I don't know about yet.

I've searched for a few hours, but all I've been able to come up with is how to assign a field to auto increment, but nothing on why it's incrementing by so many.

So my row IDs are looking like this:

1 11 21 31 41 etc.. you get the idea.

Edit: I also want to mention that in my schema, I don't have any funny business going on with the increment field. It simple looks like this: $table->increments('id');

Exactly the same as the Laravel default users Schema, but that one seems to increment just fine.

lpangm03
  • 99
  • 8
  • Can you post up the migration you are using to create the table in the database? and the code for where you are creating or updating the record? – andrew-caulfield Apr 23 '16 at 21:22
  • 1
    Have a look at this http://stackoverflow.com/questions/206751/mysql-autoincrement-column-jumps-by-10-why – Corona Apr 24 '16 at 02:06
  • Seems like some issue with your MySQL settings. – Abhishek Apr 24 '16 at 14:58
  • Try this http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_auto-increment-increment – Abhishek Apr 24 '16 at 15:01
  • Thank you guys - it turns out, it wasn't a Laravel issue at all. I am also using Azure cloud DB for the first time, and they use ClearBD. ClearBD by default uses increments of 10: https://www.cleardb.com/developers/help/faq#general_16 – lpangm03 Apr 24 '16 at 15:33

1 Answers1

-1

Ha ha that's a classic issue of transactions, seen it few times. Have you used transactions anywhere?

So what happens is even if you rollback transaction counter of id is moved on to next iteration.

Perdeep Singh
  • 517
  • 4
  • 7
  • Nope, I haven't used transactions. It's a pretty fresh project, not a whole lot has been done with it yet other than 2 tables with a couple of columns, and a form to input into the DB. – lpangm03 Apr 23 '16 at 22:17
  • Also, I should mention that this is not exclusive to my app, by the way. Even when following along with Jeffery's videos on Laracast, the ones where he creates the post and comments, the incrementation goes up by 10 there as well. – lpangm03 Apr 23 '16 at 22:19