How to create a database in doctrine 2

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

I tried using the command line, but it does not work, because first of all I need to connect to the database.

Here is the command line that I could use: enter image description here

When I use the "php doctrine dbal: run-sql CREATE DATABASE TOTO" command, I get an error message that tells me that I selected the database (but I do not want to select any database).

enter image description here

Do you have any idea how I can understand this problem?

I really appreciate it if I have no obligation to use phpmyadmin and create it myself. I would rather use a doctrine to make sure my code is compatible with another database (e.g. Mysql / Postegre)

Thanks = D

+7
source share
1 answer

I have found a solution.

You just need to indicate in your configuration file that the db name is zero.

<?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', ), ), ), ), ); 

Have a nice day every = D

+4
source

All Articles