1. Go to this page and download the library: Download shopware/dbal-nested-set 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/ */
shopware / dbal-nested-set example snippets
use Shopware\DbalNestedSet\NestedSetConfig;
$config = new NestedSetConfig(
'id', // Primary key column name
'left', // left column name
'right', // right column name
'level' // level column name
);
use Shopware\DbalNestedSet\NestedSetFactory;
use Doctrine\DBAL\Connection;
$writer = NestedSetFactory::createWriter($dbalConnection, $config);
$tableFactory = NestedSetFactory::createTableFactory($connection, $config);
$schema = new \Doctrine\DBAL\Schema\Schema();
$table = $tableFactory->createTable(
$schema,
'tree', // table name
'root_id' // nested set root id
);
$table->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
$table->addColumn('name', 'string', ['length' => 255]);
$table->setPrimaryKey(['id']);
$addSql = $schema->toSql($connection->getDatabasePlatform());