无法弄清楚为什么这个简单的代码不起作用:
$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();
包装模型:
$this->hasMany('id', 'PackItem', 'packItemId', array(
'alias' => 'packItems'
));
和PackItem模型:
$this->belongsTo('packId', 'Pack', 'id', array(
'alias' => 'pack'
));
尝试运行此代码后,错误结束:
PHP Fatal error: Maximum function nesting level of '256' reached, aborting!
日志文件中包含以下代码:
...
PHP 39. Phalcon\\Mvc\\Model->save()
PHP 40. Phalcon\\Mvc\\Model->_postSaveRelatedRecords()
PHP 41. Phalcon\\Mvc\\Model->save()
PHP 42. Phalcon\\Mvc\\Model->_preSaveRelatedRecords()
...
我没有更多的想法它是如何工作的。我使用Phalcon 3.0,在我看来这是一个bug。你觉得怎么样?