0
我有兩個實體,匹配和團隊,問題是在映射(我猜),我不想找人給我解決這個問題,只是給我一些提示,我應該在哪裏看文檔。出於某種原因,我被困在這個,並找不到解決方案..我將提供我的兩個實體的代碼。 Match.php如何解決SQLSTATE [42000]:語法錯誤或訪問衝突:1064
/**
* @var
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Team", inversedBy="matchOne")
* @ORM\JoinColumn(name="team_one_id", referencedColumnName="id")
*/
protected $teamOne;
/**
* @var
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Team", inversedBy="matchTwo")
* @ORM\JoinColumn(name="team_two_id", referencedColumnName="id")
*/
protected $teamTwo;
Team.php
/**
* @var
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Match", mappedBy="teamOne")
*/
protected $matchOne;
/**
* @var
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Match", mappedBy="teamTwo")
*/
protected $matchTwo;
問題是在我的表單類型,當我查詢的比賽,這裏是代碼
->add('match', EntityType::class, [
'class' => 'AppBundle:Match',
'choice_label' => 'getMatch',
])
而且getMatch功能
部分public function getMatch() {
return $this->getTeamOne()->getName() . ' - ' . $this->getTeamTwo()->getName();
}
表單類型用於創建新的賭注,顯然我想在下拉菜單中顯示匹配(隊名,例如:切爾西 - 利物浦)並將該匹配的編號寫入投注實體。