PHP MySQL Transactions -


Is there a way to move a SQL transaction into a command? Like

  mysql_query ("Include Start Transactions, Table 1 ... etc ... Include in Table 2 ...; Commit;");  

Or do you always have to use different commands? Like

  mysql_query ("Start Transaction;"); Mysql_query ("INS etc etc etc.  

thanks

By using PDFs instead of pure mysql statements,

  $ connection = new PDO ('mysql: host = localhost; dbname = test', 'user', 'password') ; $ Connection- $ Connection-> exec ('Insert in Table 1' ...); $ connection- & gt; exec ('Insert in Table 2 ...'); $ connection- & gt; commit ( );  

Of course, this is just a quick example, instead you should use prepared statements and bind to user input Must use Riabls so you do not have to worry much about SQL injection.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -