Re: MySQL Auto PK

From: Date: Thu, 06 Jan 2005 20:14:02 +0000
Subject: Re: MySQL Auto PK
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-38033@lists.php.net to get a copy of this message
On Friday 07 January 2005 02:29, Andrew Kreps wrote: > This would be a great place for a stored procedure, but I don't know > if I can recommend running MySQL 5 to you. The most platform-safe way > I can think of is to get a count(*) of the number of rows with today's > date, add 1 to it, and stick that number on the end of the string > you've created to insert into a varchar field. It's an extra query > per insert, but it'd do the job. Don't forget to WRITE lock the table before counting, and only unlock after inserting the new id. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db ------------------------------------------ New Year Resolution: Ignore top posted posts

« previous php.db (#38033) next »