生成:学说:实体原因异常 SQLSTATE[HY000] [1049] Base 'symfony' i


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

我是Symfony的初学者。我一步一步地按照书,在练习中 教义固定捆绑包 我遇到了这个问题。

此超越的步骤包括:

  1. 准备 Symfony-with-DoctrineFixtureBundle 的分发
  2. 打开新项目
  3. 生成捆绑包
  4. 生成访问类(php 应用程序/控制台生成:doctrine:entity)

等等。我坚持在第4点上。命令生成:doctrine:实体导致三条消息,并且没有在我的项目中创建任何实体。

三条消息

  [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>

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