douyi1197 2013-09-01 23:07
浏览 45
已采纳

如何使用Doctrine 2生成数据库?

I start with doctrine and want to create a db or php class from table with doctrine.
First i try create db. My bootstrap.php:

<?php
 use Doctrine\ORM\Tools\Setup;
 use Doctrine\ORM\EntityManager;

 require_once "vendor/autoload.php";
 require_once "src/BugRepository.php";

 $isDevMode = true;
 $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);

 $conn = array(
  'driver' => 'pdo_pgsql',
  'user' => 'postgres',
  'password' => '123456', 
  'host' => 'localhost', 
  'dbname' =>'testdata',
 );

 $entityManager = EntityManager::create($conn, $config);

and i do:

php vendor/bin/doctrine doctrine:database:create

my output:

SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../doctrine/orm/bin"
BIN_TARGET="`pwd`/doctrine"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"

But db testdatanot created.
Same with creating php class from table:

php vendor/bin/doctrine doctrine:mapping:import YourAppBundle yml --filter="bugs"  

But yml file not created.
Whats can be wrong?

展开全部

  • 写回答

1条回答 默认 最新

  • douren5898 2013-09-03 01:01
    关注

    There are also a bin folder in vendor/doctrine/orm/bin/ you can use this one like this

    php vendor/doctrine/orm/bin/doctrine orm:schema-tool:create

    make sure you have root folder and a cli-config.php file is present in root folder. https://groups.google.com/forum/#!msg/doctrine-user/_ph183Kh-5o/_P_coljB-dcJ

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部