Can't figure out why this simple code doesn't work:
$pack = new Pack();
$pack->name = 'A pack';
$packItems = array();
$packItem = new PackItem();
$packItem->pack = $pack;
$packItem->name = 'First item in the pack';
$packItems[] = $packItem;
$packItem = new PackItem();
$packItem->pack = $pack;
$packItem->name = 'Second item in the pack';
$packItems[] = $packItem;
$pack->packItems = $packItems;
$pack->save();
The Pack model:
$this->hasMany('id', 'PackItem', 'packItemId', array(
'alias' => 'packItems'
));
And the PackItem model:
$this->belongsTo('packId', 'Pack', 'id', array(
'alias' => 'pack'
));
After I try to run this code it ends on error:
PHP Fatal error: Maximum function nesting level of '256' reached, aborting!
The log file is full of code like this:
... PHP 39. Phalcon\Mvc\Model->save() PHP 40. Phalcon\Mvc\Model->_postSaveRelatedRecords() PHP 41. Phalcon\Mvc\Model->save() PHP 42. Phalcon\Mvc\Model->_preSaveRelatedRecords() ...
I don't have more ideas how it doesn't work. I use Phalcon 3.0 and It seems to me it is a bug. What do you think?