| @@ 120-138 (lines=19) @@ | ||
| 117 | * |
|
| 118 | * @return array |
|
| 119 | */ |
|
| 120 | public function getAllChildId($selectId, $order = '', array $idarray = []) |
|
| 121 | { |
|
| 122 | $selectId = (int)$selectId; |
|
| 123 | $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . ''; |
|
| 124 | if ('' !== $order) { |
|
| 125 | $sql .= " ORDER BY $order"; |
|
| 126 | } |
|
| 127 | $result = $this->db->query($sql); |
|
| 128 | $count = $this->db->getRowsNum($result); |
|
| 129 | if (0 == $count) { |
|
| 130 | return $idarray; |
|
| 131 | } |
|
| 132 | while (false !== (list($r_id) = $this->db->fetchRow($result))) { |
|
| 133 | array_push($idarray, $r_id); |
|
| 134 | $idarray = $this->getAllChildId($r_id, $order, $idarray); |
|
| 135 | } |
|
| 136 | ||
| 137 | return $idarray; |
|
| 138 | } |
|
| 139 | ||
| 140 | //returns an array of ALL parent ids for a given id($selectId) |
|
| 141 | ||
| @@ 311-329 (lines=19) @@ | ||
| 308 | * |
|
| 309 | * @return array |
|
| 310 | */ |
|
| 311 | public function getAllChild($selectId = 0, $order = '', array $parray = []) |
|
| 312 | { |
|
| 313 | $selectId = (int)$selectId; |
|
| 314 | $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . ''; |
|
| 315 | if ('' !== $order) { |
|
| 316 | $sql .= " ORDER BY $order"; |
|
| 317 | } |
|
| 318 | $result = $this->db->query($sql); |
|
| 319 | $count = $this->db->getRowsNum($result); |
|
| 320 | if (0 == $count) { |
|
| 321 | return $parray; |
|
| 322 | } |
|
| 323 | while (false !== ($row = $this->db->fetchArray($result))) { |
|
| 324 | array_push($parray, $row); |
|
| 325 | $parray = $this->getAllChild($row[$this->id], $order, $parray); |
|
| 326 | } |
|
| 327 | ||
| 328 | return $parray; |
|
| 329 | } |
|
| 330 | ||
| 331 | /** |
|
| 332 | * Enter description here... |
|