running multiple MySQL queries in batch from PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

running multiple MySQL queries in batch from PHP

Post by davidklonski »

Hello

I have an SQL file which contains numerous queries which I use in batch mode to initialize the database.

I would like to run this file from PHP.
The problem is that the file contains numerous queries while mysql_query accepts a single query.

Is there a way to run a batch of queries from PHP?
I am talking about commands like:
drop table, create table, insert...

thanks in advance
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

What i do is place each query into an element of an array, and then you can simply include the sql file and do a foreach on the array and run the sql.
Post Reply