| @@ 54-78 (lines=25) @@ | ||
| 51 | * |
|
| 52 | * @return array |
|
| 53 | */ |
|
| 54 | public function getFirstChild($sel_id, $order = '') |
|
| 55 | { |
|
| 56 | $arr = array(); |
|
| 57 | $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . (int)$sel_id . ''; |
|
| 58 | ||
| 59 | $categories = AdslightUtility::getMyItemIds('adslight_view'); |
|
| 60 | if (is_array($categories) && count($categories) > 0) { |
|
| 61 | $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') '; |
|
| 62 | } |
|
| 63 | ||
| 64 | if ('' != $order) { |
|
| 65 | $sql .= " ORDER BY $order"; |
|
| 66 | } |
|
| 67 | ||
| 68 | $result = $this->db->query($sql); |
|
| 69 | $count = $this->db->getRowsNum($result); |
|
| 70 | if (0 == $count) { |
|
| 71 | return $arr; |
|
| 72 | } |
|
| 73 | while ($myrow = $this->db->fetchArray($result)) { |
|
| 74 | array_push($arr, $myrow); |
|
| 75 | } |
|
| 76 | ||
| 77 | return $arr; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @param $sel_id |
|
| @@ 147-168 (lines=22) @@ | ||
| 144 | * |
|
| 145 | * @return array |
|
| 146 | */ |
|
| 147 | public function getAllParentId($sel_id, $order = '', $idarray = array()) |
|
| 148 | { |
|
| 149 | $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id; |
|
| 150 | ||
| 151 | $categories = AdslightUtility::getMyItemIds('adslight_view'); |
|
| 152 | if (is_array($categories) && count($categories) > 0) { |
|
| 153 | $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') '; |
|
| 154 | } |
|
| 155 | ||
| 156 | if ('' != $order) { |
|
| 157 | $sql .= " ORDER BY {$order}"; |
|
| 158 | } |
|
| 159 | $result = $this->db->query($sql); |
|
| 160 | list($r_id) = $this->db->fetchRow($result); |
|
| 161 | if (0 == $r_id) { |
|
| 162 | return $idarray; |
|
| 163 | } |
|
| 164 | array_push($idarray, $r_id); |
|
| 165 | $idarray = $this->getAllParentId($r_id, $order, $idarray); |
|
| 166 | ||
| 167 | return $idarray; |
|
| 168 | } |
|
| 169 | ||
| 170 | /** |
|
| 171 | * @param $sel_id |
|