PHP code example of valentinek / yii2-closure-table-behavior
1. Go to this page and download the library: Download valentinek/yii2-closure-table-behavior library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
valentinek / yii2-closure-table-behavior example snippets
class Category extends ActiveRecord
{
public $leaf;
public function behaviors() {
return [
[
'class' => ClosureTable::className(),
'tableName' => 'category_tree'
],
];
}
public static function find()
{
return new CategoryQuery(static::className());
}
}
class CategoryQuery extends ActiveQuery
{
public function behaviors() {
return [
[
'class' => ClosureTableQuery::className(),
'tableName' => 'category_tree'
],
];
}
}
sh
php composer.phar
sh
php yii migrate