Quote:
Originally Posted by Aaron
If you don't want a user to have the same username as another user you set that as the primary key. There is a fine reason for no auto-increment.
|
Your primary key should only be a number which exists for the sole purpose of being a constant and unique ID number. What if you want to change names?
Quote:
Originally Posted by Aaron
So... How would I have a value start at one, and go up every time a new user registers?
|
Set the primary key to auto_incriment, every time you insert a row the ID will go up one. Here is a table I used in a recent project.
[code]
CREATE TABLE `users` (
`id` int(9) NOT NULL auto_increment,
`username` varchar(255) NOT NULL,
`mail` varchar(255) NOT NULL,
`pass` varchar(255) NOT NULL,
`rank` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
[/quote]
Create that table in your database and insert a few rows.
Quote:
Originally Posted by Aaron
edit: and why does everyone have this and that as "foo" and "bar" on the explainations? My dad says that all the time and it freaks me out.
|
Just dummy values, its considered geeky (partially in jest). I just use them because I don't want to spend any time thinking over meaningless values.