Re: auto_increment problem???
| From: | Miles Thompson | Date: | Fri, 23 Aug 2002 16:11:36 +0000 |
| Subject: | Re: auto_increment problem??? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21324@lists.php.net to get a copy of this message | ||
Russ,
Check your docs to confirm this, as you are probably running a later version than I'm familiar with. If the table is defined as type "MyISAM" the autoincrement numbers do not get reused, they steadily increase. You can rely on them. The default table type is ISAM, and the autoincrement numbers do get reused.
How did I discover this? Same way you did, disappearing keys and very strange results on selects. Fortunately I discovered the difference before I had too much data, but it had me going for a while.
Cheers - Miles Thompson
At 05:29 PM 8/23/2002 +0800, Russ wrote:
G'day folks: The way I have my MySQL table set up should work as follows: 1). If table IS NOT empty, get MySQL to insert auto_increment value into primary key column as normal, then get value of previous record's second, none primary ID column. (latter column used for lookup purposes elsewhere) (This is do-able as there is already an existing record from which to gather a second none-primary ID.) 2). If table IS empty, insert auto_increment value as normal, into primary key column and *the same value* into the second, none-primary ID column. The thing is, as I'm using auto_increment as my primary key definition, and occassionally this table is emptied (deleted from), how can I get the second none primary ID column to reflect the new primary key auto_increment value of a new record, if no previous record exists?? I hope you understand what I mean! ;-) Cheers. Russ Mr Russ Michell Web Applications Developer Itomic.com Email: russ@itomic.com Tel: +61 (0)8 9321 3844 Fax: +61 (0)8 6210 1364 Post: PO Box 228, Innaloo, WA 6918, Australia Street: Suite 24, 158 William St, Perth, WA 6000, Australia "No proof of existence is not proof of non-existence." (Physicist: Stanton T. Friedman on Debunking Ufology) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php