Reply to Re: [PHP] running number

Your name:

Reply:


Posted by Roger Thomas on 07/26/05 02:32

Thanks to all that have helped. I am inclined at Robert's suggestion below that would free me from worrying about locking issues. Thanks everybody.

--
Roger

Quoting Robert Sossomon <LoneWolf@nc.rr.com>:

> CREATE TABLE `users` (
> `num` int(10) NOT NULL auto_increment,
> `name` varchar(100) NOT NULL default '',
> `login` varchar(100) NOT NULL default '',
> `password` varchar(20) NOT NULL default '',
> PRIMARY KEY (`num`),
> KEY `num` (`num`)
> ) TYPE=MyISAM AUTO_INCREMENT=12345 ;
>
> That should help out. When creating the table in mysql you can set the
> auto_increment number on the last line, which when you add a new user the
> query
> looks like:
>
> insert into users values('','name','login','pass');
>
> leaving the first field empty makes it automatically increase it. The beauty
> is
> that you can have 40000000000 people registering at once, and their number
> gets
> assigned as the query is run against the database, no matter what order they
> hit
> it in, the system will take it as they come.
>
> HTH,
> Robert
>
> Roger Thomas is quoted as saying on 7/25/2005 5:21 AM:
> > I am required to write a user registration script that captures the basics
> like name, phone number etc etc. I would also have to write to mySQL database
> a number that is associated with that user.
> >
> > At this point of writing, the start of that number is unknown. But the
> number will be incremented by 1 after each successfull registration.
> >
> > Let's say the number starts from 12345.
> >
> > I am quite new at all these stuff and would like to seek your advise on the
> *recommended way* of achieving this. I am thinking along these lines:
> > a) store that number (12345) in a table
> > b) a user registers and assign that number to him
> > c) increment number to 12346
> > d) process repeats for the next registration
> >
> > Concern: How do tell mySQL to lock the 'number' table when a new
> registration process is about to take place. Is locking the best option here
> or is/are there better ways?
> >
> > Please advise.
> >
> > --
> > Roger
> >
> >
> > ---------------------------------------------------
> > Sign Up for free Email at http://ureg.home.net.my/
> > ---------------------------------------------------
> >
>
> --
> Robert Sossomon, Business and Technology Application Technician
> 4-H Youth Development Department
> 512 BrickHaven Drive Suite 220L, Campus Box 7606
> N.C. State University
> Raleigh NC 27695-7606
> Phone: 919/515-8474
> Fax: 919/515-7812
> robert_sossomon@ncsu.edu
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>





---------------------------------------------------
Sign Up for free Email at http://ureg.home.net.my/
---------------------------------------------------

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация