代码之家  ›  专栏  ›  技术社区  ›  Rene Terstegen

MySQL的第2条配置

  •  9
  • Rene Terstegen  · 技术社区  · 14 年前

    使用sqlite,一切都可以开箱即用。但是当我尝试将沙盒演示中的数据库更改为MySQL时,我感到困惑。我就是这么做的。我创建了一个数据库,将connectionOptions数组更改为:

    $connectionOptions = array(
        'driver' => 'pdo_mysql',
        'path' => __DIR__.'/mysql.php'
    );
    

    “path”条目存在,如下所示:

    $connectionParams = array(
        'dbname' => 'db_test',
        'user' => 'test',
        'password' => 'p4ssw0rd',
        'host' => 'localhost',
        'driver' => 'pdo_mysql',
    );
    

     php doctrine orm:schema-tool:create
    

    这给了我一个错误:

     no database selected
    

    2 回复  |  直到 14 年前
        1
  •  12
  •   Darragh Enright    13 年前

    这是条令2沙盒吗?这对我有用:

    // sandbox/bootstrap.php
    
    $connectionOptions = array(
        'driver'   => 'pdo_mysql',
        'host'     => '127.0.0.1',
        'dbname'   => 'your_database_name',
        'user'     => 'username',
        'password' => 'password'
    );
    
    $em = EntityManager::create($connectionOptions, $config);
    
        2
  •  -1
  •   John Raymund    13 年前

    食谱代码也可以下载。看到了吗 here cli-config.php文件