473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

is mysql_insert_id safe

Hi all

With regard to mysql's mysql_insert_id function is it possible that the
query can return the insert id from another insert performed by a
another user of the database which occured after the initial insert by
the first user but b4 the insert_id part can be queried.
Regards

Marc

Jun 13 '06 #1
3 2253
Rik
monomaniac21 wrote:
Hi all

With regard to mysql's mysql_insert_id function is it possible that
the query can return the insert id from another insert performed by a
another user of the database which occured after the initial insert by
the first user but b4 the insert_id part can be queried.


No, mysql_insert_id() in the same script always gets the value of the last
query performed by that specific script, not by other connections to the
database.

Grtz,
--
Rik Wasmus
Jun 13 '06 #2
"monomaniac21" <mc******@googlemail.com> wrote in
news:11**********************@f6g2000cwb.googlegro ups.com:
Hi all

With regard to mysql's mysql_insert_id function is it possible that the
query can return the insert id from another insert performed by a
another user of the database which occured after the initial insert by
the first user but b4 the insert_id part can be queried.


You won't have any problems if you're running it immediately after the
query.

--
Karl Groves
www.karlcore.com
Jun 13 '06 #3
>> With regard to mysql's mysql_insert_id function is it possible that the
query can return the insert id from another insert performed by a
another user of the database which occured after the initial insert by
the first user but b4 the insert_id part can be queried.


You won't have any problems if you're running it immediately after the
query.


In the database world, there is no "immediately after". It's always
possible for someone else to get in a query between any two of
yours. It's up to locking (implicit or explicit) or transactions
to prevent bad effects on the data from this by delaying execution
of one until another finishes.

mysql_insert_id() returns the last insert id ON THIS CONNECTION.
So, as long as you keep the connection open (which probably won't
be beyond the processing of the PHP page: with persistent connections,
you are NOT guaranteed to get the same connection next time), you
can wait as long as you want to call mysql_insert_id().

Gordon L. Burditt
Jun 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kain | last post by:
hi there, I'm currently converting a MySQL application to PostgreSQL, and I hacked this app to support PEAR::Db . after some good coding days, I've found a problem: mysql_insert_id on pear::db ....
1
by: yawnmoth | last post by:
how could i reduce the following piece of code: for ($num=0;$num<50;$num++) { mysql_query($db,"INSERT INTO whatever (stuff) VALUES (somevalue);"; mysql_query($db,"INSERT INTO sometable VALUES...
9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
11
by: dee | last post by:
OleDbCommand class like many .NET classes has the following description in its help file: "Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for...
6
by: opt_inf_env | last post by:
Hi, I would like to insert a data (row) into database (MySQL) and than to generate file whose name contains the ID of the inserted row (ID is declared as AUTO_INCREMENT). I wanted to extract ID...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
2
by: Jankie | last post by:
Hi and wish all moderators and members are doing well i Back with a question after a long while,hope to find the valuable typical support from thescripts people and members. My host does not...
1
by: Fred | last post by:
if my query is a regular INSERT, then mysql_insert_id() works as expected. But if I use a Stored Procedure to do my insert, then mysql_insert_id() returns 0 How can I get a returned...
3
by: vjayis | last post by:
hi i have a form which inserts records into my table using php and to get the inserted id(auto_incremented ID) can i use this command? <? mysql_query(“insert into table(name,value)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.