我在测试文件中,我想启动一些symfony命令,即数据库,然后是drop,后跟create i create schema:
public function runCommand(Client $client, $command)
{
$application = new Application($client->getKernel());
$application->setAutoExit(false);
$fp = tmpfile();
$input = new StringInput($command);
$output = new StreamOutput($fp);
$application->run($input, $output);
fseek($fp, 0);
$output = '';
while (!feof($fp)) {
$output = fread($fp, 4096);
}
fclose($fp);
return $output;
}
public function cleanDataBaseTest() {
$client = self::createClient();
$command_drop_database = $this->runCommand($client, 'doctrine:database:drop --env=test --force');
$command_create_database = $this->runCommand($client, 'doctrine:database:create --env=test');
$command_create_schema = $this->runCommand($client, 'doctrine:schema:create --dump-sql');
echo $command_create_schema;
/*
ALTER TABLE.....
*/
}
或当我执行echo $ command_create_schema时,我只改变表。
C6 FOREIGN KEY (akey) REFERENCES atable (id);
ALTER TABLE atablea ADD CONSTRAINT FK_646DFFB72576E0FD FOREIGN KEY (anid) REFERENCES ....
所以如果我正在执行命令:php app / console doctrine:schema:create - dump-sql我得到了create和alter table
你知道为什么吗?
答案 0 :(得分:0)
sudo php bin / console doctrine:database:create
在AbstractMySQLDriver.php第125行:
驱动程序中发生异常:找不到驱动程序
在PDOConnection.php第50行:
无法找到驱动程序
在PDOConnection.php第46行:
无法找到驱动程序
doctrine:database:create [--shard SHARD] [ - connect [CONNECTION]] [--if-not-exists] [-h | --help] [-q | --quiet] [-v | vv | vvv | --verbose] [-V | --version] [--ansi] [ - no-ansi] [-n | --no-interaction] [-e | - env ENV] [ - -no-debug] [ - ]
胺@胺:/ opt / lampp / htdocs / symphart $ sudo php bin / console doctrine:database:create 胺的[sudo]密码:
在AbstractMySQLDriver.php第125行:
驱动程序中发生异常:找不到驱动程序
在PDOConnection.php第50行:
无法找到驱动程序
在PDOConnection.php第46行:
无法找到驱动程序
doctrine:database:create [--shard SHARD] [ - connect [CONNECTION]] [--if-not-exists] [-h | --help] [-q | --quiet] [-v | vv | vvv | --verbose] [-V | --version] [--ansi] [ - no-ansi] [-n | --no-interaction] [-e | - env ENV] [ - -no-debug] [ - ]