我有一个与用户实体有关的卡实体
MyBundleEntityCard:
type: entity
table: mm_card
repositoryClass: CardRepository
id:
id:
type: integer
nullable: false
unsigned: false
id: true
generator:
strategy: IDENTITY
fields:
code:
type: string
nullable: false
length: 16
manyToOne:
company:
targetEntity: User
inversedBy: companyCards
joinColumn:
name: company_id
referencedColumnName: id
nullable: false
onDelete: cascade
createdBy:
targetEntity: User
joinColumn:
name: created_by
referencedColumnName: id
nullable: true
gedmo:
blameable:
on: create
updatedBy:
targetEntity: User
joinColumn:
name: updated_by
referencedColumnName: id
nullable: true
gedmo:
blameable:
on: update
oneToOne:
owner:
targetEntity: User
joinColumn:
name: owner_id
referencedColumnName: id
nullable: true
onDelete: SET NULL
当我使用stanard crud和表单来编辑卡类时,当我选择用户并保存它时,我将与用户一起使用EntityType:类。但是,如果在API中我想这样做,ID不会:
$cardObj = $em->getRepository('MyBundle:Card')->find(16);
$userObj = $em->getRepository('MyBundle:User')->find(10);
$cardObj->setOwner($userObj);
$em->flush();
我在DB中出现错误:
An exception occurred while executing 'INSERT INTO user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, maccount_type, mcompany_type, mphoto, mphoto_guid, mcompany_code, billing_first_name, billing_last_name, billing_company, billing_phone, billing_country, billing_street, billing_building_nb, billing_local_nb, billing_city, billing_state, billing_postcode, mdescription, wp_user_id, master_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)':nnSQLSTATE[HY093]: Invalid parameter number: no parameters were bound
有人知道怎么了,如何解决它?
您出了问题.yaml配置。
查看官方文档中的示例。例如:
产品: 类型:实体 ONETOONE: 船运: 目标:运输 Joincolumn: 名称:shipping_id 引用columnname:id