小编Har*_*rry的帖子

主义2指数继承

我是Doctrine 2的新手,我试图找出如何使用它进行索引继承.

我想要实现的是拥有一个基类,它定义了一些默认列以及应用程序中所有实体的必要索引.

示例:我的应用程序中的所有表都将具有created_onmodified_on,因此我准备了一个@MappedSuperclass包含其中2列的基础.

这是我的代码:

<?php

/**
 * @MappedSuperclass
 */
abstract class EntityAbstract
{
    /**
     * @Column(type="datetime", name="created_on", nullable=false)
     */
    protected $createdOn;

    /**
     * @Column(type="datetime", name="modified_on", nullable=true)
     */
    protected $modifiedOn;

}

/**
 * @Entity
 * @Table(name="member", indexes={@Index(name="credential", columns={"email_address", "password"})})
 */
class Member extends EntityAbstract
{
    /**
     * @Column(type="string", name="full_name", length=50)
     */
    protected $fullName;

    /**
     * @Column(type="string", name="email_address", length=50, unique=true, nullable=false)
     */
    protected $emailAddress;

    /**
     * @Column(type="string", name="password", length=40, nullable=false)
     */
    protected $password;       

}
?> …
Run Code Online (Sandbox Code Playgroud)

php indexing inheritance doctrine-orm

5
推荐指数
1
解决办法
766
查看次数

标签 统计

doctrine-orm ×1

indexing ×1

inheritance ×1

php ×1