generate:doctrine:entity cause exception SQLSTATE [HY000] [1049] Base'symfony'inconnue

时间:2015-01-06 21:21:26

标签: php symfony doctrine-orm

我是Symfony的初学者。我一步一步地按照书和关于DoctrineFixturesBundle的练习我遇到了这个问题。

此例外的步骤包括:

  1. 准备分发Symfony-with-DoctrineFixtureBundle
  2. 打开新项目
  3. 生成包
  4. 生成访问类(php app / console generate:doctrine:entity)
  5. 等等。我坚持第4点。命令生成:doctrine:entity导致三条消息,并且没有在我的项目中创建任何实体。

    三条消息

      [Doctrine\DBAL\Exception\ConnectionException]
      An exception occured in driver: SQLSTATE[HY000] [1049] Base 'symfony' incon
      nue
    
      [Doctrine\DBAL\Driver\PDOException]
      SQLSTATE[HY000] [1049] Base 'symfony' inconnue
    
      [PDOException]
      SQLSTATE[HY000] [1049] Base 'symfony' inconnue
    

    我在控制台中所做的一切都在下面:

    C:\wamp\www\17CHUJNIA>php app/console generate:bundle
    
    
      Welcome to the Symfony2 bundle generator
         .    
         .
         .
      Bundle name [MyTestBundle]:
         .    
         .
         .
      Bundle generation
    
    
    Generating the bundle code: OK
    Checking that the bundle is autoloaded: OK
    Confirm automatic update of your Kernel [yes]?
    Enabling the bundle inside the Kernel: OK
    Confirm automatic update of the Routing [yes]?
    Importing the bundle routing resource: OK
    
      You can now start using the generated code!
    
    
    
    C:\wamp\www\17CHUJNIA>php app/console generate:doctrine:entity
    
    
      Welcome to the Doctrine2 entity generator
    
    
    
    The Entity shortcut name: MyTestBundle:Name
    
      [Doctrine\DBAL\Exception\ConnectionException]
      An exception occured in driver: SQLSTATE[HY000] [1049] Base 'symfony' incon
      nue
    
      [Doctrine\DBAL\Driver\PDOException]
      SQLSTATE[HY000] [1049] Base 'symfony' inconnue
    
      [PDOException]
      SQLSTATE[HY000] [1049] Base 'symfony' inconnue
    
    doctrine:generate:entity [--entity="..."] [--fields="..."] [--format="..."] [--with-repository]
    
    C:\wamp\www\17CHUJNIA>
    

1 个答案:

答案 0 :(得分:3)

您需要拥有现有数据库和有效连接才能使用此命令行。 在使用命令行处理数据库和实体之前,请检查/app/config/parameters.yml文件并创建数据库。