0
我在寻找一些帮助,为什么我在学说中的OneToMany关系只返回一个值。我的数据模型有三个表。用户,授权和应用程序。授权表是将用户映射到应用程序的粘合剂,并且还包含访问级别字段以指示其对该应用程序的访问级别。OneToMany Relationship Only Only 1 Row
我有一个用户在三个不同的应用程序的授权中有三个条目,但由于某种原因,原则只加载了这些授权记录中的一个。我已经在下面包含了我的完整数据模型。有问题的属性是Webusers表中的“授权”。
任何人都知道我在做什么错了?
class Webusers {
/**
* @var integer
*
* @ORM\Column(name="userid", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $userid;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Applications", mappedBy="userid")
*/
private $applications;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="Authorization", mappedBy="user")
*/
private $authorization;
/**
* Constructor
*/
public function __construct() {
$this->applications = new \Doctrine\Common\Collections\ArrayCollection();
$this->authorization = new \Doctrine\Common\Collections\ArrayCollection();
}
class Authorization {
/**
* @var integer
*
* @ORM\Column(name="accesslevel", type="integer", nullable=false)
*/
private $accesslevel;
/**
* @var integer
*
* @ORM\Column(name="applicationid", type="integer", nullable=false)
* $ORM\Id
*/
private $applicationid;
/**
* @var integer
*
* @ORM\Column(name="userid", type="integer", nullable=false)
* @ORM\Id
*/
private $userid;
/**
* @var \Webusers
*
* @ORM\ManyToOne(targetEntity="Webusers")
* @ORM\JoinColumn(name="userid", referencedColumnName="userid")
*/
private $user;
}
class Applications {
/**
* @var integer
*
* @ORM\Column(name="applicationid", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $applicationid;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=50, nullable=false)
*/
private $name;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Webusers", inversedBy="applicationid")
* @ORM\JoinTable(name="authorization",
* joinColumns={
* @ORM\JoinColumn(name="applicationid", referencedColumnName="applicationid")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="userid", referencedColumnName="userid")
* }
*)
*/
private $userid;
/**
* Constructor
*/
public function __construct()
{
$this->userid = new \Doctrine\Common\Collections\ArrayCollection();
}
}