HosipLan

Untitled

Sep 26th, 2011
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 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.         foreach ($ids as $id) {
  8.             $groups[$pairs[$parent]][$id] = $pairs[$id];
  9.         }
  10.     }
  11.  
  12.     return $groups;
  13. }
  14.  
  15.  
Advertisement
Add Comment
Please, Sign In to add comment