Symfony2 DB2原则:无法创建数据库

时间:2016-04-12 12:09:19

标签: php symfony doctrine db2 symfony-2.7

如果我想在DB2 docrine响应中创建我的数据库结构:

>php app/console doctrine:database:create
Could not create database "monng" for connection named default
Notice: Undefined index: dbname

但是可以从DB(读/写DB2)创建实体:

>php app/console doctrine:mapping:import AppBundle
Importing mapping information from "default" entity manager
  > writing /var/www/html/structure/src/AppBundle/Resources/config/doctrine/Projects.orm.xml

还通过CRUD创建了一个前端,我没有问题 - 可以编写/编辑/删除项目。

parameter.yml:

parameters:
    database_host: 172.25.x.y
    database_port: '60000'
    database_name: structure
    database_user: structure
    database_password: xxxxxxx
    database_driver: ibm_db2

config.yml:

...
# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
...

你有想法吗?

doctrine/doctrine-bundle             1.6.2   Symfony DoctrineBundle

修改 做了一些进一步的研究:

[_params:Doctrine\DBAL\Connection:private] => Array
        (
            [driver] => ibm_db2
            [host] => 172.25.75.10
            [port] => 60000
            [user] => monng
            [password] => monng
            [charset] => UTF8
            [driverOptions] => Array
                (
                )

            [defaultTableOptions] => Array
                (
                )

        )

2 个答案:

答案 0 :(得分:1)

解决方案似乎很简单:

只需使用" doctrine:schema:create"而不是" doctrine:database:create" for DB2-Connect

答案 1 :(得分:-1)

您可以尝试删除database_port上的引号。否则,数据库的用户结构可能无权创建?