blu*_*isk 4 symfony doctrine-orm
无法绕过它.我或多或少地从教程中复制了,但是分析器抛出了两个错误:
AppBundle\Entity\Brand关联AppBundle\Entity\Brand#devices是指不存在的拥有方字段AppBundle\Entity\Device#brands.
AppBundle\Entity\Device关联AppBundle\Entity\Device #brade是指不存在的反面字段AppBundle\Entity\Brand#brands.
class Brand {
/**
* @var int
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
...
/**
* @ORM\OneToMany(targetEntity="Device", mappedBy="brands")
*/
private $devices;
}
Run Code Online (Sandbox Code Playgroud)
和
class Device {
/**
* @var int
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
...
/**
* @ORM\ManyToOne(targetEntity="Brand", inversedBy="devices")
* @ORM\JoinColumn(name="brand_id", referencedColumnName="id", nullable=true)
*/
private $brand;
}
Run Code Online (Sandbox Code Playgroud)
没有测试过,但根据文档,它看起来应该是这样的
class Brand {
/**
* @var int
* @ORM\Column(name="brand_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
...
/**
* @ORM\OneToMany(targetEntity="Device", mappedBy="brand")
*/
private $devices;
}
Run Code Online (Sandbox Code Playgroud)
和
class Device {
/**
* @var int
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
...
/**
* @ORM\ManyToOne(targetEntity="Brand", inversedBy="devices")
* @ORM\JoinColumn(name="brand_id", referencedColumnName="id", nullable=true)
*/
private $brand;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4534 次 |
| 最近记录: |