smithaa02 Posted December 22, 2006 Share Posted December 22, 2006 Basically, I have a mysql dump with table creates and data inserts all in a giant text file. What I want to do is to put all those tables into a specified database using PHP. My questions is what is the best way to this? mysql_query() can only do one command at a time. Link to comment https://forums.phpfreaks.com/topic/31592-how-can-i-load-a-mysqldump-with-php/ Share on other sites More sharing options...
obsidian Posted December 22, 2006 Share Posted December 22, 2006 Well, depending on how large the dump file is, there are a couple different options. First, if it's not a huge file, you may be able to run a simple explode() on the semicolons that separate the queries and run each one individually. The only problem here is that if the tables contain text that may have semicolons within it, you may be in for some difficulty. If this is the case, or if the file is large (several MB), you will need to come up with some sort of regular expression match that will grab one query at a time. once you have that in place, you can simply read progressively through the file and run each query as it is completed Link to comment https://forums.phpfreaks.com/topic/31592-how-can-i-load-a-mysqldump-with-php/#findComment-146436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.