DoctrineORMModule代理和ManyToOne关联问题?

时间:2014-02-07 17:34:12

标签: doctrine-orm zend-framework2

我只是因为这件事而失去了整整一天。

当我在我的实体上添加“ManyToOne”关联时,我得到了经典的Doctrine的代理错误:

Warning: require(data/DoctrineORMModule/Proxy/__CG__TournamentEntityCountry.php): failed    to open stream: No such file or directory in /mnt/hgfs/httdocs/tournament/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 200

这里有两个实体:

namespace Tournament\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
 * @ORM\Table(options={"collate"="utf8_general_ci"})
 * @ORM\Entity
*/
class Team

{
 /**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue
 */
private $id;

/**
 * @var string
 * @ORM\Column(type="string", length=255)
 */
private $key;

/**
 * @var string
 * @ORM\Column(type="string", length=255)
 */
private $title;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $title2;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $code;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $synonyms;

/**
 * @ORM\ManyToOne(targetEntity="Country", inversedBy="teams")
 * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
 */
private $country;

/**
 * @var integer
 * @ORM\Column(name="city_id", type="integer",nullable=true)
 */
private $city;

/**
 * @var integer
 * @ORM\Column(type="integer")
 */
private $club;

/**
 * @var boolean
 */
private $national;

/**
 * @var \DateTime
 * @ORM\Column(name="created_at",type="datetime")
 */
private $created;

/**
 * @var \DateTime
 * @ORM\Column(name="updated_at",type="datetime")
 */
private $updated;

/**
 * @var groups[]
 * @ORM\ManyToMany(targetEntity="Group")
 * @ORM\JoinTable(name="Group_has_team",joinColumns={@ORM\JoinColumn(name="team_id", referencedColumnName="id")},
 *                          inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}) 
 */
private $groups;

public function __construct() 
{
    $this->groups = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
 * Set key
 *
 * @param string $key
 * @return Team
 */
public function setKey($key)
{
    $this->key = $key;

    return $this;
}

/**
 * Get key
 *
 * @return string 
 */
public function getKey()
{
    return $this->key;
}

/**
 * Set title
 *
 * @param string $title
 * @return Team
 */
public function setTitle($title)
{
    $this->title = $title;

    return $this;
}

/**
 * Get title
 *
 * @return string 
 */
public function getTitle()
{
    return $this->title;
}

/**
 * Set title2
 *
 * @param string $title2
 * @return Team
 */
public function setTitle2($title2)
{
    $this->title2 = $title2;

    return $this;
}

/**
 * Get title2
 *
 * @return string 
 */
public function getTitle2()
{
    return $this->title2;
}

/**
 * Set code
 *
 * @param string $code
 * @return Team
 */
public function setCode($code)
{
    $this->code = $code;

    return $this;
}

/**
 * Get code
 *
 * @return string 
 */
public function getCode()
{
    return $this->code;
}

/**
 * Set synonyms
 *
 * @param string $synonyms
 * @return Team
 */
public function setSynonyms($synonyms)
{
    $this->synonyms = $synonyms;

    return $this;
}

/**
 * Get synonyms
 *
 * @return string 
 */
public function getSynonyms()
{
    return $this->synonyms;
}

/**
 * Set country
 *
 * @param integer $country
 * @return Team
 */
public function setCountry($country)
{
    $this->country = $country;

    return $this;
}

/**
 * Get country
 *
 * @return integer 
 */
public function getCountry()
{
    return $this->country;
}

/**
 * Set cityId
 *
 * @param integer $cityId
 * @return Team
 */
public function setCity($cityId)
{
    $this->cityId = $cityId;

    return $this;
}

/**
 * Get cityId
 *
 * @return integer 
 */
public function getCity()
{
    return $this->cityId;
}

/**
 * Set club
 *
 * @param boolean $club
 * @return Team
 */
public function setClub($club)
{
    $this->club = $club;

    return $this;
}

/**
 * Get club
 *
 * @return boolean 
 */
public function getClub()
{
    return $this->club;
}

/**
 * Set national
 *
 * @param boolean $national
 * @return Team
 */
public function setNational($national)
{
    $this->national = $national;

    return $this;
}

/**
 * Get national
 *
 * @return boolean 
 */
public function getNational()
{
    return $this->national;
}

/**
 * Set created
 *
 * @param \DateTime $created
 * @return Team
 */
public function setCreated($created)
{
    $this->created = $created;

    return $this;
}

/**
 * Get created
 *
 * @return \DateTime 
 */
public function getCreated()
{
    return $this->created;
}

/**
 * Set updated
 *
 * @param \DateTime $updated
 * @return Team
 */
public function setUpdated($updated)
{
    $this->updated = $updated;

    return $this;
}

/**
 * Get updated
 *
 * @return \DateTime 
 */
public function getUpdated()
{
    return $this->updated;
}

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

public function getGroups()
{
        return $this->groups;
}

public function setGroups($groups)
{
        $this->groups = $groups;
}

}

国家:

namespace Tournament\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(options={"collate"="utf8_general_ci"})
 * @ORM\Entity
 */
class Country
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue
 */
private $id;

/**
 * @var string
 * @ORM\Column(type="string", length=255)
 */
private $title;

/**
 * @var string
 * @ORM\Column(type="string", length=255)
 */
private $key;

/**
 * @var string
 * @ORM\Column(type="string", length=255)
 */
private $code;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $synonyms;

/**
 * @var integer
 * @ORM\Column(type="integer")
 */
private $pop;

/**
 * @var integer
 * @ORM\Column(type="integer")
 */
private $area;

/**
 * @var integer
 * @ORM\Column(name="continent_id",type="integer",nullable=true)
 */
private $continent;

/**
 * @var integer
 * @ORM\Column(name="country_id",type="integer",nullable=true)
 */
private $country;

/**
 * @var boolean
 * @ORM\Column(type="smallint")
 */
private $s;

/**
 * @var boolean
 * @ORM\Column(type="smallint")
 */
private $c;

/**
 * @var boolean
 * @ORM\Column(type="smallint")
 */
private $d;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $motor;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $iso2;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $iso3;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $fifa;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $net;

/**
 * @var string
 * @ORM\Column(type="string", length=255,nullable=true)
 */
private $wikipedia;

/**
 * @var \DateTime
 * @ORM\Column(name="created_at",type="datetime")
 */
private $created;

/**
 * @var \DateTime
 * @ORM\Column(name="updated_at",type="datetime")
 */
private $updated;

/**
 * @var teams[]
 * @ORM\OneToMany(targetEntity="Team" , mappedBy="country")
 */
private $teams;

public function __construct() 
{
    $this->teams = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
 * Set title
 *
 * @param string $title
 * @return Country
 */
public function setTitle($title)
{
    $this->title = $title;

    return $this;
}

/**
 * Get title
 *
 * @return string 
 */
public function getTitle()
{
    return $this->title;
}

/**
 * Set key
 *
 * @param string $key
 * @return Country
 */
public function setKey($key)
{
    $this->key = $key;

    return $this;
}

/**
 * Get key
 *
 * @return string 
 */
public function getKey()
{
    return $this->key;
}

/**
 * Set code
 *
 * @param string $code
 * @return Country
 */
public function setCode($code)
{
    $this->code = $code;

    return $this;
}

/**
 * Get code
 *
 * @return string 
 */
public function getCode()
{
    return $this->code;
}

/**
 * Set synonyms
 *
 * @param string $synonyms
 * @return Country
 */
public function setSynonyms($synonyms)
{
    $this->synonyms = $synonyms;

    return $this;
}

/**
 * Get synonyms
 *
 * @return string 
 */
public function getSynonyms()
{
    return $this->synonyms;
}

/**
 * Set pop
 *
 * @param integer $pop
 * @return Country
 */
public function setPop($pop)
{
    $this->pop = $pop;

    return $this;
}

/**
 * Get pop
 *
 * @return integer 
 */
public function getPop()
{
    return $this->pop;
}

/**
 * Set area
 *
 * @param integer $area
 * @return Country
 */
public function setArea($area)
{
    $this->area = $area;

    return $this;
}

/**
 * Get area
 *
 * @return integer 
 */
public function getArea()
{
    return $this->area;
}

/**
 * Set continent
 *
 * @param integer $continent
 * @return Country
 */
public function setContinent($continent)
{
    $this->continent = $continent;

    return $this;
}

/**
 * Get continent
 *
 * @return integer 
 */
public function getContinent()
{
    return $this->continent;
}

/**
 * Set country
 *
 * @param integer $country
 * @return Country
 */
public function setCountry($country)
{
    $this->country = $country;

    return $this;
}

/**
 * Get country
 *
 * @return integer 
 */
public function getCountry()
{
    return $this->country;
}

/**
 * Set s
 *
 * @param boolean $s
 * @return Country
 */
public function setS($s)
{
    $this->s = $s;

    return $this;
}

/**
 * Get s
 *
 * @return boolean 
 */
public function getS()
{
    return $this->s;
}

/**
 * Set c
 *
 * @param boolean $c
 * @return Country
 */
public function setC($c)
{
    $this->c = $c;

    return $this;
}

/**
 * Get c
 *
 * @return boolean 
 */
public function getC()
{
    return $this->c;
}

/**
 * Set d
 *
 * @param boolean $d
 * @return Country
 */
public function setD($d)
{
    $this->d = $d;

    return $this;
}

/**
 * Get d
 *
 * @return boolean 
 */
public function getD()
{
    return $this->d;
}

/**
 * Set motor
 *
 * @param string $motor
 * @return Country
 */
public function setMotor($motor)
{
    $this->motor = $motor;

    return $this;
}

/**
 * Get motor
 *
 * @return string 
 */
public function getMotor()
{
    return $this->motor;
}

/**
 * Set iso2
 *
 * @param string $iso2
 * @return Country
 */
public function setIso2($iso2)
{
    $this->iso2 = $iso2;

    return $this;
}

/**
 * Get iso2
 *
 * @return string 
 */
public function getIso2()
{
    return $this->iso2;
}

/**
 * Set iso3
 *
 * @param string $iso3
 * @return Country
 */
public function setIso3($iso3)
{
    $this->iso3 = $iso3;

    return $this;
}

/**
 * Get iso3
 *
 * @return string 
 */
public function getIso3()
{
    return $this->iso3;
}

/**
 * Set fifa
 *
 * @param string $fifa
 * @return Country
 */
public function setFifa($fifa)
{
    $this->fifa = $fifa;

    return $this;
}

/**
 * Get fifa
 *
 * @return string 
 */
public function getFifa()
{
    return $this->fifa;
}

/**
 * Set net
 *
 * @param string $net
 * @return Country
 */
public function setNet($net)
{
    $this->net = $net;

    return $this;
}

/**
 * Get net
 *
 * @return string 
 */
public function getNet()
{
    return $this->net;
}

/**
 * Set wikipedia
 *
 * @param string $wikipedia
 * @return Country
 */
public function setWikipedia($wikipedia)
{
    $this->wikipedia = $wikipedia;

    return $this;
}

/**
 * Get wikipedia
 *
 * @return string 
 */
public function getWikipedia()
{
    return $this->wikipedia;
}

/**
 * Set created
 *
 * @param \DateTime $created
 * @return Country
 */
public function setCreatedAt($created)
{
    $this->created = $created;

    return $this;
}

/**
 * Get created
 *
 * @return \DateTime 
 */
public function getCreated()
{
    return $this->created;
}

/**
 * Set updated
 *
 * @param \DateTime $updated
 * @return Country
 */
public function setUpdated($updated)
{
    $this->updated = $updated;

    return $this;
}

/**
 * Get updated
 *
 * @return \DateTime 
 */
public function getUpdated()
{
    return $this->updated;
}

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

public function getTeams()
{
        return $this->teams;
}

public function setTeams($teams)
{
        $this->teams = $teams;
}

}

文件/文件夹权限完全正确......

1 个答案:

答案 0 :(得分:0)

太愚蠢了。在Doctrine的配置中将'generate_proxies'标志设置为false ...当您在共享项目中工作时会发生这种情况:P