我正在尝试使用扩展名“NestedSetBehvaior”保存节点:http ://www.yiiframework.com/extension/nestedsetbehavior/
但它没有在数据库中保存任何东西..
我尝试使用扩展附带的架构(extensions/yiiext/behaviors/trees/schema.sql)..
我还添加了未包含的“标题”列。
然后我用 Gii 生成了控制器、模型和 CRUD,并将其添加到新创建的模型中:Category.php
public function behaviors()
{
return array(
'nestedSetBehavior'=>array(
'class'=>'ext.yiiext.behaviors.model.trees.NestedSetBehavior',
'leftAttribute'=>'lft',
'rightAttribute'=>'rgt',
'levelAttribute'=>'level',
),
);
}
我还将 NestedSetBehavior.php 放在 protected/extensions/yiiext/behaviors/model/trees/
然后我将它添加到控制器 indexAction 中:
$root=new Category;
$root->title='Mobile Phones';
$root->saveNode();
什么可能是错的?
此外,您会推荐哪种方法为多个用户(3000+)存储多个树?想象一棵深度无限的树..