If I have 2 models Str and StrTranslations, where StrTranslations belongsTo Str. And if I i add new parent record (Str) with StrTranslations encapsulated as related Like
$myStr = new Str(); //$myStr->id = null; //want new ID from DB $_related = new StrTranslations(); //$_related->strid = null; //want to use $myStr->id assigned after DB INSERT $_related->value = "blabla"; $myStr->StrTranslations = $_related; $myStr->save();
As you could notice i wanna to have myStr->id to be assigned by by DB insert, not by PHP code and after that wanna to reuse same id in related myStr->StrTranslations
Diggin the Mozel.zep https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model.zep it looks like first Phalcon saves related records ($myStr->StrTranslations), not parent record ($myStr) by calling preSaveRelatedRecords() then saves parent record by calling _doLowInsert()/doLowUpdate() then re-saves related records _postSaveRelatedRecords() So related records actually are saved twice with same parent->save() call.
am I right ? It is not clear to me why related are saved first if anyway all saving happens withing a transation automatically ?