drbigfresh Posted September 23, 2007 Share Posted September 23, 2007 I know I used to be able to do this in asp and sql, but I hven't been able to get it to work in PHP and MySQL.... Is there some way to build a long query using new lines, and then execute it once... For example: $sql = "insert into test (animal) values ('dog')\n"; $sql = $sql . "insert into invoices (invoicenos) values ('123')\n"; $sql = $sql . "insert into users (email) values ('asdasd@somewhere.com')\n"; $db->Execute($sql) or die($db->ErrorMsg()); in asp/sql I could do it by seperating the queries with & VCBRLF and SQL would interpret each query separately.... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/70384-possible/ Share on other sites More sharing options...
teng84 Posted September 23, 2007 Share Posted September 23, 2007 have you tried it? Quote Link to comment https://forums.phpfreaks.com/topic/70384-possible/#findComment-353631 Share on other sites More sharing options...
mezise Posted September 24, 2007 Share Posted September 24, 2007 Hi, yes, it is possible, but using Improved MySQL Extension function mysqli_multi_query() or its OO version. The only difference is that you need to use semicolon as a separator. You will find the details on this manual page: http://www.php.net/mysqli_multi_query . Michal Quote Link to comment https://forums.phpfreaks.com/topic/70384-possible/#findComment-353823 Share on other sites More sharing options...
fenway Posted September 24, 2007 Share Posted September 24, 2007 Why on earth would you want to do this? Quote Link to comment https://forums.phpfreaks.com/topic/70384-possible/#findComment-354127 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.