| @@ 2-25 (lines=24) @@ | ||
| 1 | <?php |
|
| 2 | class NestedSet extends CActiveRecord |
|
| 3 | { |
|
| 4 | public static function model($className=__CLASS__) |
|
| 5 | { |
|
| 6 | return parent::model($className); |
|
| 7 | } |
|
| 8 | ||
| 9 | public function behaviors() |
|
| 10 | { |
|
| 11 | return array( |
|
| 12 | 'tree'=>array( |
|
| 13 | 'class'=>'ext.NestedSetBehavior', |
|
| 14 | 'hasManyRoots'=>false, |
|
| 15 | ), |
|
| 16 | ); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function rules() |
|
| 20 | { |
|
| 21 | return array( |
|
| 22 | array('name','required'), |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | } |
|
| 26 | ||
| @@ 2-25 (lines=24) @@ | ||
| 1 | <?php |
|
| 2 | class NestedSetWithManyRoots extends CActiveRecord |
|
| 3 | { |
|
| 4 | public static function model($className=__CLASS__) |
|
| 5 | { |
|
| 6 | return parent::model($className); |
|
| 7 | } |
|
| 8 | ||
| 9 | public function behaviors() |
|
| 10 | { |
|
| 11 | return array( |
|
| 12 | 'tree'=>array( |
|
| 13 | 'class'=>'ext.NestedSetBehavior', |
|
| 14 | 'hasManyRoots'=>true, |
|
| 15 | ), |
|
| 16 | ); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function rules() |
|
| 20 | { |
|
| 21 | return array( |
|
| 22 | array('name','required'), |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | } |
|