I am trying to save a new line to a quote, but Yii does not save QuoteRow. It saves only the new service (yes, the database structure is a bit strange). I don't seem to understand. If the string is not saved, $ qr-> save () returns false, but it is not. The service was successfully inserted, but there is no cover.
$service = new Services; $service->label = $row['title'] ?: "Övrigt"; $service->is_priced_per_unit = 1; $service->price_per_unit = $row['price']*0.8; $service->is_default = 0; $service->rot_deductable = (int)isset($row['rot']); $service->rot_deduction_percentage = 0.5; if (!$service->save()) $this->addError('Kunde inte spara raden',$service->getErrors()); else{ $qr = new QuoteRows; $qr->quote_service_id = Yii::app()->db->getLastInsertID(); $qr->quote_id = $id; $qr->unit_size = $row['amount'] ?: 0; $qr->raw_price = $row['price']*0.8*($row['amount'] ?: 1); $qr->is_rot_deductable = isset($row['rot']) ? 1 : 0; $qr->is_active = 1; if (!$qr->save()) $this->addError('Kunde inte spara raden',$qr->getErrors()); }
If $ qr is not saved, I should get errors. I also tried checking $ qr with the validate function, and it claims to be perfectly true!
source share