public static function treeLinhvucPhong($parentid = 0, $level = 0, &$result) { $db = JFactory::getDbo(); if (!$result) { $result = array(); } //khoi tao 1 array co ten la arr //var_dump($colums['parentid']);exit; //var_dump($colums['parentid'].' = '.$parentid);exit; $query = $db->getQuery(true)->select(array('id', 'tenlinhvuc AS name', 'parent_id'))->from('cb_type_linhvuc'); if ($parentid == 0) { $query->where('parent_id IS NULL'); } else { $query->where('parent_id = ' . $parentid); } $query->where('type = 1'); //var_dump($query->__toString()); $db->setQuery($query); $rows = $db->loadAssocList(); // for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; $result[] = array('id' => $row['id'], 'name' => $row['name'], 'parent' => $row['parent_id'], 'level' => $level); $result = TochucHelper::treeLinhvucTochuc($row['id'], $level + 1, $result); } return $result; }