[development] auto_increment

Chris Johnson chris at tinpixel.com
Tue Dec 13 16:54:42 UTC 2005


Rowan Kerr wrote:
> On 12/13/05, Piotr Krukowiecki <piotr at mallorn.ii.uj.edu.pl> wrote:
> 
>>On Mon, Dec 12, 2005 at 11:46:11PM +0100, Gerhard Killesreiter wrote:
>>
>>>Right. I still prefer to get the nid in advance. It just feels safer. :p
>>
>>False feeling ;) I don't see how it's safer.
> 
> 
> Requesting an ID in advance is also a database-dependent feature.
> MSSQL and others let you do it through their built-in support of
> sequences, but MySQL only has auto-increment as far as I know.
> 
> As convenient as auto-increment is, I think it will be harder to work
> around that if/when Drupal is moved to other databases than it is to
> use sequences.
> 
> -Rowan
> 
> 

Right.  MySQL is the exception or odd one out, here.  Most databases support 
sequences and transactions.  MySQL has consistently been the database missing 
features and/or having non-standard extensions.

Killes' preference for getting the nid in advance may not be safer, but it is 
certainly no less safe and at the same time more portable and SQL standard.

I've almost never *needed* auto_increment in applications I have developed, 
although I have used it from time to time for convenient unique keys. 
Sometimes I think people who use auto_increment and mysql_insert_id() are 
either using the wrong algorithm to accomplish what they want, or they don't 
know better.


..chrisxj



More information about the development mailing list