我有以下表格:
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)
所有可本地化的文本都存储在一个表中,以及连接到该表的所有其他表。
我不知道如何编写 Country 模型?这就是我到目前为止的方式。
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 实体获取 Country 或任何实体。但我不想制作一个连接表,因为它有点矫枉过正,而且完全没有意义。