I have a weird performance when I try to insert data in a table.
For some reason, my model isn’t insertig records in the table, but, the auto increment is working.
In the log, I find the sql statement generated by the model and it works plus I don’t get any validation error.
$transaction = Yii::$app->db->beginTransaction();
...
$pago = new Pago();
$pago->prestamo_id = Yii::$app->request->post("prestamo_id");
$pago->cliente_id = Yii::$app->request->post("cliente_id");
if (!$pago->validate()) {
foreach ($pago->errors as $key => $error) {
$messages .= $error[0] . "\n";
}
return $this->asJson(['success' => false, 'message' => $messages]);
}
if (!$pago->save()) {
$transaction->rollBack();
foreach ($pago->errors as $key => $error) {
$messages .= $error[0] . "\n";
}
return $this->asJson(['success' => false, 'message' => $messages]);
}