我在使用zend framework 2和postgresql
的doctrine-module控制台时遇到问题ricardo@notebook:/var/www/zendskeleton$ bin/doctrine-module orm:schema-tool:create
PHP Warning: array_map(): An error occurred while invoking the map callback in /var/www/zendskeleton/vendor/doctrine/doctrine-orm-module/src/DoctrineORMModule/Module.php on line 138
Warning: array_map(): An error occurred while invoking the map callback in /var/www/zendskeleton/vendor/doctrine/doctrine-orm-module/src/DoctrineORMModule/Module.php on line 138
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] FATAL: database "zend" does not exist' in /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('pgsql:host=loca...', 'postgres', 'morphy09', Array)
#1 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php(46): Doctrine\DBAL\Driver\PDOConnection->__construct('pgsql:host=loca...', 'postgres', 'postgres', Array)
#2 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOPgSql\Driver->connect(Array, 'postgres', 'postgres', Array)
#3 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
#4 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#5 /var/www/zendskeleton/vendor/doctrine/dbal/li in /var/www/zendskeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 930
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] FATAL: database "zend" does not exist' in /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('pgsql:host=loca...', 'postgres', 'postgres', Array)
#1 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php(46): Doctrine\DBAL\Driver\PDOConnection->__construct('pgsql:host=loca...', 'postgres', 'postgres', Array)
#2 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOPgSql\Driver->connect(Array, 'postgres', 'postgres', Array)
#3 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
#4 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#5 /var/www/utilcore/vendor/doctrine/dbal/li in /var/www/zendskeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 930
我有一个doctrine.local.php配置文件:
<?php
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'driverClass' =>'Doctrine\DBAL\Driver\PDOPgSql\Driver',
'params' => [
'host' => 'localhost',
'port' => '5432',
'user' => 'postgres',
'password' => 'postgres',
'dbname' => 'zend',
]
]
]
]
];
基本上,我无法使用doctrine-module cli命令创建我的数据库。
为什么我收到此错误?
如果我使用psql创建数据库,所有doctrine-module命令都能很好地工作,但是doctrine-module orm:schema-tool:create就是为了这个?
答案 0 :(得分:1)
发生错误是因为doctrine尝试在名为zend
的数据库中创建表,并且此数据库不存在。您应该检查数据库设置,看看是否有名为zend
的数据库。