INSERT INTO Table_5 (data1) VALUES ('some data') $conn = sqlsrv_connect( $serverName, $connectionOptions ) $connectionOptions = array("Database"=>"dbName", "UID"=>"username", "PWD"=>"password") (it's not tested and contains pseudo code): I would just like to add something to Brian's reply which might suit your scenario, especially with the transaction, hope you don't mind Brian. This is the way the SQL client is designed to run. You can run all of your commands in a single script, and check the result of each statement as it gets executed. Is there a way to pass the variable to the next query? Or is there a much easier way to reach this goal? I can't believe I'm the first person coming up with this as it seems to be a quite basic problem to me. Therefore I always get a rollback as the third query doesn't know the variable I wrote all the queries in one string my error handling would be useless as I need to check each query for errors seperately. Unfortunately I don't see a way to pass the variable holding the new created ID to the next query. So I would split the code obove in 3 different querys, run them checking for errors and commit if there weren't any. VALUES I use sqlsrv_query with sqlsrv_commit and sqlsrv_rollback to make sure the data is value and ether all queries are run or no one. INSERT INTO table2 (foreignkey,field2,field2.)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |