[PHP] Re: excuting several sql statements in one time
No you can't! I wrote a simple routine for the task! you might want to view it from: http://www.kameelah.org/eassoft/php_files/sql2php.php.txt just take the parse_sql_stream($all) which returns an array that have all the statments to be passed to mysql_query() this script is usefull when you have a huge .SQL file that you want to execute from PHP code. VM ÁÖ¿N [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello I want to know how to implement these several sql statements in one time. For example, I have 2 sql statements like : INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); Then, I want to excute these 2 sql statements in one time with PHP. I tried to implement like this : $query = INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); ; mysql_query($query, $dbconnect); But as you know, it didn't work. Does any one know how to run this job? _ MSN Explorer°¡ ÀÖÀ¸¸é Hotmail »ç¿ëÀÌ ÈξÀ Æí¸®ÇØ Áý´Ï´Ù. Áö±Ý http://explorer.msn.co.kr/ ¿¡¼ ¹«·á·Î ´Ù¿î·ÎµåÇϼ¼¿ä. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: excuting several sql statements in one time
yes, it will not work,because mysql does not support it(the way you try to use is 'procedure' called in MS SQL sever) , mysq developer said they will accomplish in the further . you and I have to wait for it. VM ÁÖ¿N [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello I want to know how to implement these several sql statements in one time. For example, I have 2 sql statements like : INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); Then, I want to excute these 2 sql statements in one time with PHP. I tried to implement like this : $query = INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); ; mysql_query($query, $dbconnect); But as you know, it didn't work. Does any one know how to run this job? _ MSN Explorer°¡ ÀÖÀ¸¸é Hotmail »ç¿ëÀÌ ÈξÀ Æí¸®ÇØ Áý´Ï´Ù. Áö±Ý http://explorer.msn.co.kr/ ¿¡¼ ¹«·á·Î ´Ù¿î·ÎµåÇϼ¼¿ä. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: excuting several sql statements in one time
Hey, Whilst you can't perform statements like this, there are alternatives. If you only have one field in your table, you can use: INSERT INTO com VALUES ('pentium'), ('amd'); // Continue the comma separated values list Or, if you need to specify which fields the data is to go in: INSERT INTO com (column1, column2) VALUES ('something', 'something else'), ('something again', 'something else again'); James VM ÁÖ¿N [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello I want to know how to implement these several sql statements in one time. For example, I have 2 sql statements like : INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); Then, I want to excute these 2 sql statements in one time with PHP. I tried to implement like this : $query = INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); ; mysql_query($query, $dbconnect); But as you know, it didn't work. Does any one know how to run this job? _ MSN Explorer¡Æ¢® AOA¢¬¢¬e Hotmail ¡íc¢¯eAI EI¨úA ¨¡i¢¬RC¨ª Ay¢¥I¢¥U. Ao¡¾Y http://explorer.msn.co.kr/ ¢¯¢®¨ù¡© ©ö¡ì¡¤a¡¤I ¢¥U¢¯i¡¤I¥ìaCI¨ù¨ù¢¯a. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: excuting several sql statements in one time
This is more of a MySQL question, but: Actually, as of MySQL version 3.22.5, INSERT statements can have multiple value lists. In your case, this would be $query = INSERT INTO com VALUES . ('pentium'), ('amd'); mysql_query($query, $dbconnect) or die(mysql_error()); Also, you don't need a trailing ';' on the SQL query statement (you DO need it, of course, at the end of the PHP statement). See http://www.mysql.com/doc/I/N/INSERT.html for more information. -steve At 11:58 AM +0200 9/20/01, _lallous wrote: No you can't! I wrote a simple routine for the task! you might want to view it from: http://www.kameelah.org/eassoft/php_files/sql2php.php.txt just take the parse_sql_stream($all) which returns an array that have all the statments to be passed to mysql_query() this script is usefull when you have a huge .SQL file that you want to execute from PHP code. VM ¡÷øN [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello I want to know how to implement these several sql statements in one time. For example, I have 2 sql statements like : INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); Then, I want to excute these 2 sql statements in one time with PHP. I tried to implement like this : $query = INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); ; mysql_query($query, $dbconnect); But as you know, it didn't work. Does any one know how to run this job? -- + Open source questions? + | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]