SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry laravel, I have tried all solution on iternet. I am getting this error when adding new record, strang things is I am not getting this all time but error coming on every 2nd or 3rd record.
This I start noticing after import data from Backup
- I have truncate table and create from migration, but after importing old records still same issue.
- Have tried resetting auto increment field.
in controller I have tried 2 ways given below
'''
$data = array(
'hospital_id' => $hospitalid,
'doctor_name' => 'newdoc',
'doctor_id' => $this->myGUID(),
'created_at' => NOW(),
'updated_at' => NOW(),
'status' => 0,
'slug' => $docslug
);
$doctor_id = Doctor::create($data)->id;
$doct = new Doctor();
$doct->hospital_id = $hospitalid;
$doct->doctor_name = 'newdoc';
$doct->doctor_id = $this->myGUID();
$doct->slug = $docslug;
$doct->created_at = NOW();
$doct->updated_at = NOW();
$doct->status = 0;
$doct->save();
'''
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3Cq3Rhq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire