duanping2809 2014-07-16 11:46
浏览 50

在Zend框架2中生成实体形成现有数据库

I already have a database with two tables "Album" and "Email". I tried to generate orm and entities from that using commands.

First I used the following command to generate orm

/opt/lampp/bin/php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:convert-mapping --from-database php ./module/Album/src/Album/Entity

That creates orm files as follows..

use Doctrine\ORM\Mapping\ClassMetadataInfo;

 $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
 $metadata->setPrimaryTable(array(
    'name' => 'Album',
   ));
 $metadata-   
>setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT);
 $metadata->mapField(array(
    'fieldName' => 'id',
    'columnName' => 'id',
    'type' => 'integer',
    'nullable' => false,
    'unsigned' => false,
   'comment' => '',
   'id' => true,
  ));
$metadata->mapField(array(
   'fieldName' => 'artist',
   'columnName' => 'artist',
   'type' => 'string',
   'nullable' => false,
   'length' => 255,
   'fixed' => false,
   'comment' => '',
  ));
$metadata->mapField(array(
   'fieldName' => 'title',
   'columnName' => 'title',
   'type' => 'string',
   'nullable' => false,
   'length' => 255,
   'fixed' => false,
   'comment' => '',
  ));
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY);

After that I run the below command to generate entities from that orm files

/opt/lampp/bin/php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:generate-entities /modules/Album/src/Album/Entity

But, the last command returns the error in command prompt like..

Notice: Undefined variable: metadata in /opt/lampp/htdocs/ZendSkeleton/module/Album/src/Album/Entity/Album.php on line 5

Fatal error: Call to a member function setInheritanceType() on a non-object in /opt/lampp/htdocs/ZendSkeleton/module/Album/src/Album/Entity/Album.php on line 5

The $metadata variable is undefined...

Is there any thing wrong in what I did...?

How should I proceed next...? Please help me....

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度