Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 05 Oct 2011, 20:03
sweeps78 sweeps78 is offline
 
Join Date: Sep 2006
process for creating a new id for a new product "post"

It's been a long time since I did some serious php and database work so bear with me

I have a product I'm working on that consists of a thread/post architecture. What I'm working on now is trying to figure out how to create a new ID for when inserting new records in the DB. Normally, I would think that I would just do a count on the records of that table and add 1 to create a new unique ID, but going through some other products people have created I see things like "$cleanfileid = $vbulletin->input->clean_gpc('r', 'id', TYPE_UINT);" being used a lot so I was curious if vBulletin already has a prebuilt function to generate new IDs.
Reply With Quote
  #2  
Old 05 Oct 2011, 20:19
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I think the way it works in vb is that there's a database column defined as auto_increment so whenever you add a record, that field is automatically set to the next value. Then if you need the new id in your code you can call $db->insert_id() to get the value from the last insert.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 14:35.

Layout Options | Width: Wide Color: