我已经关注了这个网站上的一些问题,但仍然无法弄清楚我的设置有什么问题。我被难住了一段时间。抱歉,如果这是一个基本错误,我对 Doctrine 还是很陌生。谢谢你。
我得到的错误是:
Error: Class models\\Classes_users has no association named users_username...
查询是:
SELECT u FROM models\Classes_users c JOIN c.users_username u WHERE c.class_id = 1
实体:
/**
* models\Classes_users
*
* @Table(name="classes_users")
* @Entity
*/
class Classes_users
{
...
/**
* @var string $users_username
*
* @Id
* @ManyToOne(targetEntity="Users", inversedBy="users_username")
* @JoinColumn(name="users_username", referencedColumnName="users_username")
* @Column(name="users_username", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $users_username;
...
}
/**
* models\Users
*
* @Table(name="users")
* @Entity
*/
class Users
{
....
/**
* @var string $users_username
* @Id
* @OneToMany(targetEntity="Classes_users", mappedBy="users_username")
* @Column(name="users_username", type="string")
*/
private $users_username;
....
}