@@ 114-132 (lines=19) @@ | ||
111 | * |
|
112 | * @return array |
|
113 | */ |
|
114 | public function getAllChildId($selectId, $order = '', $idarray = array()) |
|
115 | { |
|
116 | $selectId = (int)$selectId; |
|
117 | $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . ''; |
|
118 | if ($order !== '') { |
|
119 | $sql .= " ORDER BY $order"; |
|
120 | } |
|
121 | $result = $this->db->query($sql); |
|
122 | $count = $this->db->getRowsNum($result); |
|
123 | if (0 == $count) { |
|
124 | return $idarray; |
|
125 | } |
|
126 | while (false !== (list($r_id) = $this->db->fetchRow($result))) { |
|
127 | array_push($idarray, $r_id); |
|
128 | $idarray = $this->getAllChildId($r_id, $order, $idarray); |
|
129 | } |
|
130 | ||
131 | return $idarray; |
|
132 | } |
|
133 | ||
134 | //returns an array of ALL parent ids for a given id($selectId) |
|
135 | /** |
|
@@ 303-321 (lines=19) @@ | ||
300 | * |
|
301 | * @return array |
|
302 | */ |
|
303 | public function getAllChild($selectId = 0, $order = '', $parray = array()) |
|
304 | { |
|
305 | $selectId = (int)$selectId; |
|
306 | $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . ''; |
|
307 | if ($order !== '') { |
|
308 | $sql .= " ORDER BY $order"; |
|
309 | } |
|
310 | $result = $this->db->query($sql); |
|
311 | $count = $this->db->getRowsNum($result); |
|
312 | if (0 == $count) { |
|
313 | return $parray; |
|
314 | } |
|
315 | while (false !== ($row = $this->db->fetchArray($result))) { |
|
316 | array_push($parray, $row); |
|
317 | $parray = $this->getAllChild($row[$this->id], $order, $parray); |
|
318 | } |
|
319 | ||
320 | return $parray; |
|
321 | } |
|
322 | ||
323 | /** |
|
324 | * Enter description here... |