In a nutshell, I’m making a booking app. Booking id needs to start at 10000 and increase by one each new booking.
I’ve started coding a method to generate this booking number. What I’m struggling with is:
- On first run, there will be no booking numbers so I can’t simply add 1 to the last id in the database table. I need a way to check if the last number does in fact have a base of 10000.
I’m using cake php and the way I’m getting the id number is using
$ids = $this->find('first', array('order' => 'Booking.id DESC', 'fields' => 'Booking.id'));
Any ideas?
You could either re-create the
Bookingtable or alter it so that theidfield starts at 10000.Re-Create:
Or Alter:
You would only have to do this once. Afterward, you could be a lot more sure that the last Booking id was 10000 or greater.