我已经声明了我的实体的ID:
/**
* @ORMId @ORMColumn(type="integer") @ORMGeneratedValue
*/
protected $id;
但是,每次我尝试在表格之后保存我的数据库时,我都会得到" 0",因此给出:Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'
我的存储逻辑如下:
public function CallManager($data)
{
$callRequested= new CallRequested;
$callRequested-> setClientContact($data['clientContact']);
$callRequested-> setProvider($data['provider']);
$callRequested-> setCallCenter($data['callCenterContact']);
$whenCall= $data['schedule'];
$language= $data['language'];
$date = new DateTime();
$callRequested-> setRequestTime($date);
var_dump($data);
$this->entityManager->persist($callRequested);
$this->entityManager->flush();
}
我该怎么办?
您需要告诉它,您希望它像这样自动提出:
/**
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
* @ORMColumn(type="integer")
*/
private $id;