Auto increment (MYSQL) or (PHP)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalp1200
Forum Newbie
Posts: 19
Joined: Tue Aug 26, 2008 8:57 pm

Auto increment (MYSQL) or (PHP)

Post by kalp1200 »

Hi,

What is the best way to do auto incrementing for tables in the database. The default way in the mysql database allows you to increment, but when you delete, it leaves a gap and continues with the next following number.

Q1 – Can mysql trigger herlp
Q2 - It can be done from the client side, but how do I go about it..
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Auto increment (MYSQL) or (PHP)

Post by requinix »

kalp1200 wrote:What is the best way to do auto incrementing for tables in the database. The default way in the mysql database allows you to increment, but when you delete, it leaves a gap and continues with the next following number.
That is the best way.

I'd quote them if I remembered where the post was, but auto_increment fields are supposed to be unique and never, ever repeated. If something gets deleted it doesn't matter: the id number was used in the past and cannot be used again.

If you need to reuse those numbers then you're doing something the wrong way.
Post Reply