I am getting bellow error recently my currently using app. when try to insert record using eloquent. This code was perfectly working in past few months. Now it just throwing the error after '1303' records inserted.
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicata du champ '1304' pour la clef 'PRIMARY' (SQL: insert into
orderrequest
Translate from: English SQLSTATE [23000]: Integrity constraint violation: 1062 Duplicate field '1304' for the 'PRIMARY' key (SQL: insert into orderrequest
$today = date("Y-m-d H:i:s");
$order = OrderModel::find($id);
$kot = new OrderrequestModel;
$kot->orid = $id;
$kot->location = $order->location;
$kot->provider = "kitchen";
$orderitems =OrderitemModel::where('orid', '=', $id)->get();
$total = 0;
foreach ($orderitems as $orderitem) {
//$total = $total+($orderitem->price * $orderitem->qty);
if($orderitem->provider=="kitchen"){
$kot->token .= '<tr>
<td align="left">'.$orderitem->fiid.'</td>
<td align="left">'.$orderitem->item.'</td>
<td align="center">'.$orderitem->provider.'</td>
<td align="center">'.$orderitem->qty.'</td>
</tr>';
$orderitem->isreq = "k";
$orderitem->save();
}
}
$kot->token .= '</table>';
$kot->type = "full";
$kot->save();
primary id
in your table. – Nitesh Vermaprimary_key
is notauto incrimantal
– Gayan