Description
Discussed in #16203
Originally posted by slechtic November 11, 2022
Hi,
I'm trying to migrate from Phalcon v3 to v5 but I have a problem with updating related entity.
I have an entity Document and this entity has related entity DocumentHistory.
On Document entity there is hasMany relationship defined:
$this->hasMany('id', DocumentHistory::class, 'idDocument', ['alias' => 'documentHistories']);
DocumentHistory entity has belongsTo relationship:
$this->belongsTo('idDocument', Document::class, 'id',['alias' => 'document']);
when I create new DocumentHistory entity and assign existing Document entity, change some values on this entity (Document) and save DocumentHistory entity, only DocumentHistory is saved (created). Document entity is not updated but foreign key is set on DocumentHistory entity correctly. In case when both entities exist it works correctly.
$documentHistory = new DocumentHistory();
$document = Document::findFirst($id);
$document->setNumber($number);
$documentHistory->setDocument($document);
$documentHistory->save();
On DocumentHistory there is a setter:
public function setDocument(Document $document) {
$this->document = $document;
}
This works for Phalcon v3. This will not be supported in v5 or it is a bug? Thank you.
My environent:
PHP 8.1.
Phalcon 5.1.0.
Postgresql 11
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog