Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require dir(__FILE__).'/tree.php';
- try {
- $pdo = new PDO( 'mysql:dbname=db;host=localhost', 'admin', 'qwerty' );
- } catch ( Exception $e ) {
- echo 'Connection failed: ' . $e->getMessage();
- }
- Tree::SetConnection($pdo);
- //Создание структуры страниц
- Tree::Fixture( 'pages', 1000, 5 );
- //Построение дерева из таблицы по ключу parent_id
- $arr = Tree::GetTree( 'pages' );
- //echo '<pre>'.print_r ( $arr, 1 ).'</pre>';
- //Построение путей в таблице
- $time = microtime(true);
- Tree::GeneratePaths('pages');
- echo microtime(true)-$time.' с.';
- //Путь к элементу
- $arr = Tree::GetPath('pages', 700);
- echo '<pre>'.print_r ( $arr, 1 ).'</pre>';
- //Получение всех детей
- $arr = Tree::GetChildren('pages', 40);
- echo '<pre>'.print_r ( $arr, 1 ).'</pre>';
- //Количество детей
- echo Tree::GetChildrenCount('pages', 2);
Advertisement
Add Comment
Please, Sign In to add comment