HosipLan

Untitled

Sep 26th, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. public function getGroups()
  2. {
  3.     $result = $this->db->select('*')->from('tabulka')->execute();
  4.     $pairs = $result->fetchPairs('id|name');
  5.     $groups = array();
  6.     foreach ($result->fetchAssoc('parent[]=id') as $parent => $ids) {
  7.         $group = &$groups[$pairs[$parent]];
  8.         foreach ($ids as $id) {
  9.             $group[$id] = $pairs[$id];
  10.         }
  11.     }
  12.  
  13.     return $groups;
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment