我宣佈我的實體的ID:生成的ID總是0
/**
* @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue
*/
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();
}
我該怎麼辦?
你確定一行代碼是要幫助別人理解你的問題,給你正確的解決方案。我們在這裏不是NECROMANCER。請提供更多細節。 [閱讀如何問一個很好的問題](https://stackoverflow.com/help/how-to-ask) –