0

I have an application with this directory tree:

3.0    
    3.0.0
         patch1.sql
         patch2.sql
    3.0.1
         ...
    3.0.2
         ...
    3.0.3
         ...
3.1
    3.1.0
    3.1.1
4.0
    4.0.0
    4.0.1
    4.0.2

In every directory I have 1 or more file sql file.

How I can execute these sql file trough php? I need to have the response back (in case of errors).

I found this command, but how I can check for errors?

mysql -u yourusername -p yourpassword yourdatabase < sql_file
peterh
  • 11,875
  • 18
  • 85
  • 108
  • Review the help section for info on the types of questions that are allowed on SO, and how to ask a question. SO is not a code writing service. You need to show that you have done research, and show what you have tried. – Sloan Thrasher May 11 '17 at 09:23
  • I'm not searching for someone write the code. I'm searching for the best way for do it. –  May 11 '17 at 09:47
  • Then do as I suggested and review the help section. – Sloan Thrasher May 11 '17 at 09:49
  • Use a function like `shell_exec` to execute a shell command from PHP. – Barmar May 11 '17 at 10:34
  • See http://stackoverflow.com/questions/2014474/php-read-sub-directories-and-loop-through-files-how-to for how to loop through all the directories to find the `.sql` files. – Barmar May 11 '17 at 10:36
  • But how I check errors with `shell_exec()` ? –  May 11 '17 at 13:29

0 Answers0