Page 1 of 1
seeking advice on how to implement user ids
Posted: Sat Jun 21, 2003 9:25 am
by m3rajk
i want each user to have his or her own id number, assigned incrementally, but i'm not sure how ot set this up.
does anyone have suggestions on how to set this up so i avoid the isssue of two people submitting in close enough sucession thatone gets a number, the second one pulls the same number, and then the recod is updated?
Posted: Sat Jun 21, 2003 9:28 am
by Zeceer
It is MYSQL you use as database?
Posted: Sat Jun 21, 2003 11:16 am
by m3rajk
yes... i am waiting till i figure this out to initialize it thought
Posted: Sat Jun 21, 2003 11:18 am
by nielsene
I beleive MySQL has an "AUTO INCREMENT" default/type that you can use with your primary key column.
Posted: Sat Jun 21, 2003 12:50 pm
by m3rajk
nice. i haven't experimented much with mysql and figured i'd do as much as possible in php since that's what i'm trying to show off with the site. but yeah, definitely going to take the mysql autoincrement route.
Posted: Sat Jun 21, 2003 1:11 pm
by Zeceer
Yes. MYSQL has a Auto Increment. Just sign this future to a table when creating it.
Posted: Sat Jun 21, 2003 9:36 pm
by nielsene
m3rajk wrote:nice. i haven't experimented much with mysql and figured i'd do as much as possible in php since that's what i'm trying to show off with the site. but yeah, definitely going to take the mysql autoincrement route.
Its always worth getting familar with what tools and functionality your data-store/database brings to your application before deciding what to implement in application code. Functionality that is builtin to your database is going to be faster, more secure, and less maintainence than anything written in PHP at the application level, at least 99.9% of the time.
The best way to show off PHP is to take full advantage of the database you use so your PHP code is simpler and faster. If you're going to be developing websites more than just once, it would be a good idea to look into reading up on:
Relational Database Theory (an absolutely amazing book is Chris Date's
Introduction to Database Systems )
SQL : (I used Osborne Publishings,
The Complete Reference SQL)
and a book/manual on the database you're using such as MySQL or PostGreSQL.
The RDB Theory books will help you understand what a database is all about and what a good database should be able to do for you. SQL books will teach you how almost all current database systems work(none are true Relational DB's, however, but knowing the theory will help you design good systems, even in an imperfect implementation). Finally the vendor specific book will help you avoid the gotcha's of any vendors trouble spots.)