登録しようのない一方向の関係:単一のテーブルに格納symfonyの1対多のテーブル
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エンティティから取得できません。しかし、私は結合テーブルを作ることを望んでいません、その種の過労、そして全く無意味なので。
は、なぜそれが行き過ぎ/無意味なのですか? –
**企業**テーブルとテーブルを接続したいですか? –
あなたは私の答えを見ることができます。答えがあなたにいくつかの啓発を与えることができるかもしれません。 –