本文介绍了如何在学说中创建数据库2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用doctrine 2和zend框架2创建一个数据库。

I would like to create a database with doctrine 2 and zend framework 2.

我试图使用命令行,但它不起作用,因为首先我需要连接到一个数据库。

I tried to use the command line but it doesn't work because first of all I need to be connected to a database.

这是我可以使用的命令行:

Here is the command line that I could use :

当我使用命令php doctrine dbal:run-sql CREATE DATABASE TOTO时,我收到一个错误,告诉我我选择的数据库(但我不想选择任何数据库)是未知的。

When I use the command "php doctrine dbal:run-sql CREATE DATABASE TOTO", I receive an error which tells me that I the database that I selected (but I don't want to select any database) is unknown.

你有什么想法可以弄清楚这个问题吗?

Do you have any idea how I can figure out this problem ?

如果我没有义务使用phpmyadmin并由我自己创建,我真的很感激。我更喜欢使用doctrine来确保我的代码与其他类型的数据库(如Mysql / Postegre)兼容

I really appreciate if I not obliged to use phpmyadmin and create it by my own. I'll prefer to use doctrine to make sure that my code is compatible with other kind of database (such as Mysql/Postegre)

谢谢= D

推荐答案

我找到了解决方案。

您只需在配置文件中指定dbname等于null。

You just have to specify in your configuration file that the dbname is equals to null.

<?php
return array (
  'doctrine' => array (
'connection' =>
array (
  'orm_default' =>
  array (
    'driverClass' => 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver',
    'params' =>
    array (
      'host' => 'localhost',
      'port' => '3306',
      'user' => 'root',
      'password' => '',
      'dbname' => null,
      'charset' => 'UTF8',
    ),
  ),
  'orm_poems' =>
  array (
    'driverClass' => 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver',
    'params' =>
    array (
      'host' => 'localhost',
      'port' => '3306',
      'user' => 'root',
      'password' => 'mot de passe',
      'dbname' => 'poemsV3',
      'charset' => 'UTF8',
    ),
  ),
),
  ),
);

每个人都有一个美好的一天= D

Have a good day everybody =D

这篇关于如何在学说中创建数据库2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 19:21