There is a table of deal, which consists of id, name, connect_deal. The last column contains the id of the related row of the same table, if any. To remove values from connect_deal, I run the following code:
$deal = Deal::findOne($id); $conId = $deal->connectDeal; $deal->connectDeal = null; if ($deal->save()) { $upDeal = Deal::findOne($conId); $upDeal->connectDeal = null; $result = $upDeal->save(); if ($result) { Yii::$app->session->setFlash('success', 'Связь успешно удалена'); return $this->refresh(); } } .... As a result, the data is deleted, as I need, but it turns out an error, the debugger allocates the line $upDeal->connectDeal = null; and displays the warning Creating default object from empty value , while $deal->connectDeal = null does not cause any questions to the program. What could be the error and how to solve it?