|
|
@ -83,6 +83,29 @@ class m150722_150100_multiple_tree extends Migration |
|
|
|
```php |
|
|
|
```php |
|
|
|
use paulzi\nestedsets\NestedSetsBehavior; |
|
|
|
use paulzi\nestedsets\NestedSetsBehavior; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @property integer $id |
|
|
|
|
|
|
|
* @property integer $lft |
|
|
|
|
|
|
|
* @property integer $rgt |
|
|
|
|
|
|
|
* @property integer $depth |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @method getParents($depth = null) |
|
|
|
|
|
|
|
* @method getParent() |
|
|
|
|
|
|
|
* @method getRoot() |
|
|
|
|
|
|
|
* @method getDescendants($depth = null, $andSelf = false, $backOrder = false) |
|
|
|
|
|
|
|
* @method getChildren() |
|
|
|
|
|
|
|
* @method getLeaves($depth = null) |
|
|
|
|
|
|
|
* @method getPrev() |
|
|
|
|
|
|
|
* @method getNext() |
|
|
|
|
|
|
|
* @method populateTree($depth = null) |
|
|
|
|
|
|
|
* @method isRoot() |
|
|
|
|
|
|
|
* @method isLeaf() |
|
|
|
|
|
|
|
* @method makeRoot() |
|
|
|
|
|
|
|
* @method prependTo($node) |
|
|
|
|
|
|
|
* @method appendTo($node) |
|
|
|
|
|
|
|
* @method deleteWithChildren() |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class Sample extends \yii\db\ActiveRecord |
|
|
|
class Sample extends \yii\db\ActiveRecord |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function behaviors() { |
|
|
|
public function behaviors() { |
|
|
@ -291,4 +314,4 @@ To delete a node with descendants: |
|
|
|
$node11 = Sample::findOne(['name' => 'node 1.1']); |
|
|
|
$node11 = Sample::findOne(['name' => 'node 1.1']); |
|
|
|
$node11->delete(); // delete node, children come up to the parent |
|
|
|
$node11->delete(); // delete node, children come up to the parent |
|
|
|
$node11->deleteWithChildren(); // delete node and all descendants |
|
|
|
$node11->deleteWithChildren(); // delete node and all descendants |
|
|
|
``` |
|
|
|
``` |
|
|
|