tags:

views:

38

answers:

2

I store such sqls in a text file:

insert into table ...;
...
insert into table ...;

How to executable all those statements with PHP? It seems mysql_query() can only execute 1 statement every time.

UPDATE

The reason I don't do it in command line like this

mysql -u your_user_name -p -D your_database_name < your_sql_file.txt;

is that it won't work when there's multi-byte characters in your_sql_file.txt, will get stuff like 梵天眼

A: 
Alan Haggai Alavi
+2  A: 
$txt = file_get_contents('FILE.txt');
$queries = explode(';', $txt);
foreach($queries as $sql){
   mysql_query($sql)
}
rahim asgari