通过 Symfony 原则更新表时,我偶尔会收到“违反完整性约束:1062 Duplicate entry ... for key 'PRIMARY'”错误。该表是使用相应的历史表创建的。错误不是来自更新表本身,而是来自在历史表中插入记录。我正在使用 Symfony 1.4,学说 1.2。知道是什么原因造成的吗?谢谢。
$this->computer = $computerTable->findOneByMacAddress($this->props['mac_address']);
$this->computer->ip_address = $this->ip;
$this->computer->setLastCheckinAt(date('Y-m-d H:i:s')) ;
$this->computer->save();
schema.yml
Computer:
actAs:
Timestampable: ~
History:
className: %CLASS%History
auditLog: true
deleteVersions: false
cascadeDelete: false
columns:
mac_address: { type: string(13), notnull: true, }
last_checkin_at: { type: string(60), }
ip_address: { type: string(40), fixed: false, notnull: false, }
...