我有一个关于symfony2的问题。如何在控制器中执行mysql命令?有点像导入。我尝试了execute()但无济于事(也没有出现任何错误):mysql -u username –-password = password database_name <file.sql
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
$process = new Process('mysql -u username –-password=password database_name < file.sql');
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
http://symfony.com/doc/current/components/process.html#usage
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句