| @@ 119-136 (lines=18) @@ | ||
| 116 | * @param array $idarray |
|
| 117 | * @return array |
|
| 118 | */ |
|
| 119 | public function getAllChildId($sel_id, $order = '', $idarray = array()) |
|
| 120 | { |
|
| 121 | $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . ''; |
|
| 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 | //returns an array of ALL parent ids for a given id($sel_id) |
|
| 139 | ||
| @@ 342-359 (lines=18) @@ | ||
| 339 | * @param array $parray |
|
| 340 | * @return array |
|
| 341 | */ |
|
| 342 | public function getAllChild($sel_id = 0, $order = '', $parray = array()) |
|
| 343 | { |
|
| 344 | $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . ''; |
|
| 345 | if ($order !== '') { |
|
| 346 | $sql .= " ORDER BY $order"; |
|
| 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 |
|