Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Eri Laksmono  >  Tree Query  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example file
Class: Tree Query
Generate conditions to get tree elements
Author: By
Last change: mengubah debug() menjadi print_r
Date: 11 months ago
Size: 3,060 bytes
 

Contents

Class file image Download
<?php

require_once('tree_query.php');

$data = array(
    array(
        
'id'=>'1',
        
'atribut'=>'categories',
        
'value'=>'shopping',
        
'depth'=>'0',
        
'parent_id'=>'0'
    
),
    array(
        
'id'=>'2',
        
'atribut'=>'categories',
        
'value'=>'registrasi',
        
'depth'=>'0',
        
'parent_id'=>'0'
    
),
    array(
        
'id'=>'3',
        
'atribut'=>'categories',
        
'value'=>'edit_profil',
        
'depth'=>'0',
        
'parent_id'=>'0'
    
),

    
//LEVEL 2
    
array(
        
'id'=>'4',
        
'atribut'=>'categories',
        
'value'=>'baju',
        
'depth'=>'1',
        
'parent_id'=>'1'
    
),
    array(
        
'id'=>'5',
        
'atribut'=>'categories',
        
'value'=>'celana',
        
'depth'=>'1',
        
'parent_id'=>'1'
    
),
    array(
        
'id'=>'6',
        
'atribut'=>'categories',
        
'value'=>'jaket',
        
'depth'=>'1',
        
'parent_id'=>'1'
    
),

    
//LEVEL 3
    
array(
        
'id'=>'7',
        
'atribut'=>'categories',
        
'value'=>'hem',
        
'depth'=>'2',
        
'parent_id'=>'4'
    
),
    array(
        
'id'=>'8',
        
'atribut'=>'categories',
        
'value'=>'oblong',
        
'depth'=>'2',
        
'parent_id'=>'4'
    
),
    array(
        
'id'=>'9',
        
'atribut'=>'categories',
        
'value'=>'panjang',
        
'depth'=>'2',
        
'parent_id'=>'5'
    
),
    array(
        
'id'=>'10',
        
'atribut'=>'categories',
        
'value'=>'pendek',
        
'depth'=>'2',
        
'parent_id'=>'5'
    
),
    array(
        
'id'=>'11',
        
'atribut'=>'categories',
        
'value'=>'kulit',
        
'depth'=>'2',
        
'parent_id'=>'6'
    
),
    array(
        
'id'=>'12',
        
'atribut'=>'categories',
        
'value'=>'kain',
        
'depth'=>'2',
        
'parent_id'=>'6'
    
),

    
//LEVEL 4
    
array(
        
'id'=>'13',
        
'atribut'=>'items',
        
'value'=>'hem1',
        
'depth'=>'3',
        
'parent_id'=>'7'
    
),
    array(
        
'id'=>'14',
        
'atribut'=>'items',
        
'value'=>'hem2',
        
'depth'=>'3',
        
'parent_id'=>'7'
    
),
    array(
        
'id'=>'15',
        
'atribut'=>'items',
        
'value'=>'kaos oblong1',
        
'depth'=>'3',
        
'parent_id'=>'8'
    
),
    array(
        
'id'=>'16',
        
'atribut'=>'items',
        
'value'=>'kaos oblong2',
        
'depth'=>'3',
        
'parent_id'=>'8'
    
),
    array(
        
'id'=>'17',
        
'atribut'=>'items',
        
'value'=>'celana panjang1',
        
'depth'=>'3',
        
'parent_id'=>'9'
    
),
    array(
        
'id'=>'18',
        
'atribut'=>'items',
        
'value'=>'celana panjang2',
        
'depth'=>'3',
        
'parent_id'=>'9'
    
),
    array(
        
'id'=>'19',
        
'atribut'=>'items',
        
'value'=>'celana pendek1',
        
'depth'=>'3',
        
'parent_id'=>'10'
    
),
    array(
        
'id'=>'20',
        
'atribut'=>'items',
        
'value'=>'celana pendek2',
        
'depth'=>'3',
        
'parent_id'=>'10'
    
),
    array(
        
'id'=>'21',
        
'atribut'=>'items',
        
'value'=>'jaket kulit 1',
        
'depth'=>'3',
        
'parent_id'=>'11'
    
),
    array(
        
'id'=>'22',
        
'atribut'=>'items',
        
'value'=>'jaket kulit 2',
        
'depth'=>'3',
        
'parent_id'=>'11'
    
),
    array(
        
'id'=>'23',
        
'atribut'=>'items',
        
'value'=>'jaket kain 1',
        
'depth'=>'3',
        
'parent_id'=>'12'
    
),
    array(
        
'id'=>'24',
        
'atribut'=>'items',
        
'value'=>'jaket kain 2',
        
'depth'=>'3',
        
'parent_id'=>'12'
    
)
);



$tree = new tree_query($data);

$getParents $tree->getParents( array('id'=>'24') );
print_r($getParents);

print_r($tree->getData$getParents ));
?>