Re: Taking care of an auto_increment field!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Is there a way to use transactios in MySQL??

Of course. They only work properly with innodb tables though. This is all in the mysql documentation (http://dev.mysql.com)

Or maybe using a global variable accesed by all the processes running in the server?

You could create a global 'sequence' table and use that to get the id's.

create table my_sequence(id int auto_increment);

when you need a new number,

$query = "update my_sequence set id=last_insert_id(id+1)";
$result = mysql_query($query);
$new_id = mysql_insert_id();

Or actually creating the auto_increment fields by inserting as many rows needed, but what if the user cancels the operatuion?

What difference does that make? You'll have id's in the sequence but not used anywhere. No big deal.


PS: Can you get rid of all that other crap when you send to a mailing list? Sign up for a gmail or hotmail account or something (if you need an invite let me know).

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux