Fae*_*ery 15 php symfony doctrine-orm
我有一个包含Products的表和另一个包含Notes的表.每种产品都可以有或没有一些注释.我只需要注意知道他们所提到的产品,但产品不知道它的注释.我认为这应该是我的代码:
namespace EM\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use EM\MyBundle\Entity\Productss;
/**
* @ORM\Entity
* @ORM\Table(name="notes")
*/
class Notess
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @OneToOne(targetEntity="Productss")
* @JoinColumn(name="products_id", referencedColumnName="id")
**/
private $products;
//...
}
namespace EM\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="domains")
*/
class Domains
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// ...
}
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误:[Doctrine\Common\Annotations\AnnotationException]
[语义错误]从未导入属性EM\MyBundle\Entity\Notes :: $ products中的注释"@OneToOne".您是否忘记为此注释添加"使用"语句?
你能帮我解决这个问题吗?
Jam*_*all 55
我觉得你本来打算用@ORM\OneToOne......
/**
* @ORM\OneToOne(targetEntity="Productss")
* @ORM\JoinColumn(name="products_id", referencedColumnName="id")
*/
private $products;
//...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19423 次 |
| 最近记录: |