ENTITY Utente:
<?php
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="Utente")
*/
class Utente extends BaseUser {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToMany(targetEntity="Sede", inversedBy="proprietario,codice")
* @ORM\JoinTable(name="utente_sede")
*/
protected $sedi;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->sedi = new \Doctrine\Common\Collections\ArrayCollection();
}
ENTITY Sede:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="Sede")
*/
class Sede {
/**
* @ORM\ManyToMany(targetEntity="Utente", mappedBy="sedi")
**/
protected $utenti;
public function __construct() {
$this->utenti = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* @ORM\ManyToOne(targetEntity="proprietario")
* @ORM\JoinColumn(name="proprietario", referencedColumnName="id_proprietario")
* @ORM\Id
* */
protected $proprietario;
/**
* @ORM\Column(type="string",length=30)
* @ORM\Id
* @Assert\Regex("/^(0[0-9][0-9]|100)$/")
*/
protected $codice;
我使用复合键创建了ManyToMany(UTENTE&lt; =&gt; SEDE)关系:
Sedi表有主键:proprietario,codice
Utente表有主键:id
接下来尝试命令app \ console&#34; &#34; - ANSI&#34; &#34;教义:模式:更新&#34; &#34; - 力&#34;
DOCTRYNE返回此错误。
[学说\ ORM \ ORMException]
从AppBundle \ Entity \ Utente towar的关系引用的列名id
ds AppBundle \ Entity \ Sede不存在。