我有以下表格:Symfony的一个一对多的单向关系,而不JOIN表
strings
------
"id" int not null primary key
string_texts
------
"id" int not null primary key
"string_id" int not null fk(strings.id)
"language_id" int not null fk(languages.id)
"text" text
"countries"
------
"id" int not null primary key,
"name_id" int not null fk(strings.id)
存储在一个表中的所有本地化的文本,并连接到该表中的每个其他表。
我不知道如何编写国家模式?这是我到目前为止的。
namespace LoginHood\HoodBundle\Entity\Geo;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
class Country
{
/**
* @var int
*
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
*/
protected $id;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="StringText", mappedBy="")
*/
protected $names;
/*
...
*/
public function __construct()
{
$this->names = new ArrayCollection();
}
}
由于该结构,您无法从StringText实体获取国家或任何实体。但我不想制作一个连接表,因为它有点矫枉过正,而且毫无意义。
为什么它是矫枉过正/毫无意义? –
你想连接**公司**表与哪个表? –
你可以看到我的答案。可能的答案可以给你一些启示。 –