I have been using MySQL variables in my SQL code. For example:
$sql = "SELECT @authorID := authorID FROM Author WHERE authorName = 'Tom'";
mysql_query($sql,$db);
$sql = "UPDATE BOOK SET authorID = @authorID WHERE title = 'TomsBook'";
mysql_query($sql,$db);
Anyway the code above has been working for me. The DB remembers the value of @authorID acorss the two different calls to mysql_query. I am concerned about how this will work in a multiuser environment? Is it possible that different users will overwrite each others variables? Are there any other drawbacks to this approach?
I know I could go in and pull out the result from the first query into PHP and then put it back into the second query string, however, since the I don't need the variable except for in the second query I would rather not. Also I know that the above example could be written as a single query, however, that is not practical with some of the queries I am working with.
Thank you,