Forum Moderators: coopster

Message Too Old, No Replies

PHP/MySQL select of transaction query

PHP/MySQL select of transaction query

         

npulis

10:22 am on Jan 9, 2010 (gmt 0)



Hi,

Is it possible to affect a SELECT statement of an INSERT during a transaction to affect another INSERT?

Example:

Start Transaction
Run Query which involves an auto increment field
Check what is assigned with auto increment
Affect another statement which involves the auto increment value
Commit

Thanks a bunch :)

Psychopsia

2:18 pm on Jan 9, 2010 (gmt 0)

10+ Year Member



Hello! I think so. Did you tried already?

// start transaction

$sql = 'INSERT...

$new_id = mysql_insert_id();

$sql = 'INSERT INTO table (some_field) VALUES (' . $new_id . ')';

// end transaction

Something like that.

npulis

2:26 pm on Jan 9, 2010 (gmt 0)



Thanks dude, managed to work it out. Was doing it wrong :)

I Should have done just a select :)