一对一的自我引用问题

时间:2013-09-28 19:23:02

标签: php doctrine-orm

我正在尝试在Doctrine 2中实现一对一的自引用关系。所以,我的实体Membro_model是:

<?php
/**
*
* @Entity
* @Table(name="tb_membro")
*/
class Membro_model
{
    /**
    * @Id @Column(type="integer")
    * @GeneratedValue(strategy="IDENTITY")
    */
    public $id = 0;

    /**
    * @Column(type="string", columnDefinition="VARCHAR(50) NOT NULL")
    */
    public $nome = 0;


    /**
    * @Column(type="string", columnDefinition="VARCHAR(50) NOT NULL")
    */
    public $email = 0;

    /**
    * @Column(type="string", columnDefinition="VARCHAR(12) NOT NULL")
    */
    public $login = 0;

   /**
    * @OneToOne(targetEntity="Membro_model")
    * @JoinColumn(name="patrocinador_id", referencedColumnName="id")
    **/
    public $patrocinador;

}

我可以坚持实体。我在恢复数据时遇到问题。当字段patrocinador_id为NULL时,我在恢复时没有问题,但是当字段不为NULL时,会出现以下错误:

Fatal error: require(): Failed opening required 
'application//models/proxies\__CG__Membro_model.php' 
(include_path='.;C:\php\pear') in C:\Program Files\EasyPHP-DevServer-
13.1VC9\data\localweb\eliteapp\application\third_party\DoctrineORM-
2.2.2\libraries\Doctrine\ORM\Proxy\ProxyFactory.php on line 93

我正在尝试使用findOneBy恢复:

$membro = $this->doctrine->em->getRepository('Membro_model')->findOneBy(array('login' => $login));

0 个答案:

没有答案