doctrine での OneToMany 関係が 1 つの値しか返さない理由について、助けを求めています。私のデータ モデルには 3 つのテーブルがあります。ユーザー、承認、およびアプリケーション。Authorization テーブルは、ユーザーをアプリケーションにマップする接着剤であり、そのアプリケーションに対するユーザーのアクセス レベルを示す accesslevel フィールドも含まれています。
3 つの異なるアプリケーションの承認に 3 つのエントリを持つユーザーがいますが、何らかの理由で、doctrine はそれらの承認レコードの 1 つしかロードしていません。完全なデータ モデルを以下に示します。問題の属性は、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();
}
}