| @@ 113-136 (lines=24) @@ | ||
| 110 | * |
|
| 111 | * @return array |
|
| 112 | */ |
|
| 113 | public function getAllChildId($sel_id, $order = '', $idarray = array()) |
|
| 114 | { |
|
| 115 | $sql = 'SELECT SQL_CACHE ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $this->db->escape($sel_id) . ''; |
|
| 116 | ||
| 117 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
|
| 118 | if (is_array($categories) && count($categories) > 0) { |
|
| 119 | $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') '; |
|
| 120 | } |
|
| 121 | ||
| 122 | if ($order != '') { |
|
| 123 | $sql .= " ORDER BY {$order}"; |
|
| 124 | } |
|
| 125 | $result = $this->db->query($sql); |
|
| 126 | $count = $this->db->getRowsNum($result); |
|
| 127 | if ($count == 0) { |
|
| 128 | return $idarray; |
|
| 129 | } |
|
| 130 | while (list($r_id) = $this->db->fetchRow($result)) { |
|
| 131 | array_push($idarray, $r_id); |
|
| 132 | $idarray = $this->getAllChildId($r_id, $order, $idarray); |
|
| 133 | } |
|
| 134 | ||
| 135 | return $idarray; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @param $sel_id |
|
| @@ 145-166 (lines=22) @@ | ||
| 142 | * |
|
| 143 | * @return array |
|
| 144 | */ |
|
| 145 | public function getAllParentId($sel_id, $order = '', $idarray = array()) |
|
| 146 | { |
|
| 147 | $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $this->db->escape($sel_id) . ''; |
|
| 148 | ||
| 149 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
|
| 150 | if (is_array($categories) && count($categories) > 0) { |
|
| 151 | $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') '; |
|
| 152 | } |
|
| 153 | ||
| 154 | if ($order != '') { |
|
| 155 | $sql .= " ORDER BY {$order}"; |
|
| 156 | } |
|
| 157 | $result = $this->db->query($sql); |
|
| 158 | list($r_id) = $this->db->fetchRow($result); |
|
| 159 | if ($r_id == 0) { |
|
| 160 | return $idarray; |
|
| 161 | } |
|
| 162 | array_push($idarray, $r_id); |
|
| 163 | $idarray = $this->getAllParentId($r_id, $order, $idarray); |
|
| 164 | ||
| 165 | return $idarray; |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * @param $sel_id |
|
| @@ 335-359 (lines=25) @@ | ||
| 332 | * |
|
| 333 | * @return array |
|
| 334 | */ |
|
| 335 | public function getAllChild($sel_id = 0, $order = '', $parray = array()) |
|
| 336 | { |
|
| 337 | $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $this->db->escape($sel_id) . ''; |
|
| 338 | ||
| 339 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
|
| 340 | if (is_array($categories) && count($categories) > 0) { |
|
| 341 | $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') '; |
|
| 342 | } |
|
| 343 | ||
| 344 | if ($order != '') { |
|
| 345 | $sql .= " ORDER BY {$order}"; |
|
| 346 | } |
|
| 347 | ||
| 348 | $result = $this->db->query($sql); |
|
| 349 | $count = $this->db->getRowsNum($result); |
|
| 350 | if ($count == 0) { |
|
| 351 | return $parray; |
|
| 352 | } |
|
| 353 | while ($row = $this->db->fetchArray($result)) { |
|
| 354 | array_push($parray, $row); |
|
| 355 | $parray = $this->getAllChild($row[$this->id], $order, $parray); |
|
| 356 | } |
|
| 357 | ||
| 358 | return $parray; |
|
| 359 | } |
|
| 360 | ||
| 361 | /** |
|
| 362 | * @param int $sel_id |
|