Pre Exam Test Practice
Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
running mysql sql files in php
running mysql sql files in php ¬†using -'php,mysql,zend-framework,scripting'
I have two *.sql files that I use when creating a new web site database. ¬†The first file creates all the tables. ¬†The second file populates some default records. ¬†I would like to execute these files from PHP. ¬†I also use the Zend_Framework, if that will help accomplish this.
I don't have console access
I'm trying to automate site generation from within our application.
$command = 'mysql'
¬†¬†¬†¬†¬†¬†¬†¬†. ' --host=' . $vals['db_host']
¬†¬†¬†¬†¬†¬†¬†¬†. ' --user=' . $vals['db_user']
¬†¬†¬†¬†¬†¬†¬†¬†. ' --password=' . $vals['db_pass']
¬†¬†¬†¬†¬†¬†¬†¬†. ' --database=' . $vals['db_name']
¬†¬†¬†¬†¬†¬†¬†¬†. ' --execute="SOURCE ' . $script_path
$output1 = shell_exec($command . '/site_db.sql"');
$output2 = shell_exec($command . '/site_structure.sql"');
...I never did get useful output, but followed some suggestions on another thread and finally got it all working. ¬†I switch to the --option=value format for the commands and used --execute="SOURCE ..." instead of < to execute the file.
Also, I never got a good explanation of the difference between shell_exec() and exec().
Sep 24, 2015
to add a comment.
Related Hot Questions
Government Jobs Opening