last_insert_id and mysql_insert_id
#1

Title says it all, but what's the difference between last_insert_id and mysql_insert_id? As far as I know, is last_insert_id updates the ID and stuff Or is it the same as mysql_insert_id. I've tried mysql_insert_id once, but when I deleted a column it doesn't update the IDs when it was like 1,2,3,4 and deleted 2. But it continues with 5. I've searched about it but can't really understand it well... Need some explanation please ^_^
Reply
#2

You should not reuse primary key indexes when deleting elements. It won't update anything, only return the ID of last element inserted ( http://dev.mysql.com/doc/refman/5.0/...last-insert-id mroe info)
Reply
#3

So what about an example of BanID? When there's 1, 2, 3, 4 and I unban ID 2 and when I ban a player, that player will get BanID 2. How can I do that?
Reply
#4

1. Add field to users table, called banID, with NULL allowed values
2. Create table bans
3. Create relation between banID in users table, with id in bans table
4. Store all bans history in bans table, but keep only most recent in banID field for specific user (or NULL if user isn't banned)
5. You can also add userID field in bans table, with relation to users.id field, so your bans history track can be more useful
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)