| @@ 117-135 (lines=19) @@ | ||
| 114 | * |
|
| 115 | * @return array |
|
| 116 | */ |
|
| 117 | public function getAllChildId($sel_id, $order = '', $idarray = array()) |
|
| 118 | { |
|
| 119 | $sel_id = (int)$sel_id; |
|
| 120 | $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . ''; |
|
| 121 | if ($order != '') { |
|
| 122 | $sql .= " ORDER BY $order"; |
|
| 123 | } |
|
| 124 | $result = $this->db->query($sql); |
|
| 125 | $count = $this->db->getRowsNum($result); |
|
| 126 | if ($count == 0) { |
|
| 127 | return $idarray; |
|
| 128 | } |
|
| 129 | while (list($r_id) = $this->db->fetchRow($result)) { |
|
| 130 | array_push($idarray, $r_id); |
|
| 131 | $idarray = $this->getAllChildId($r_id, $order, $idarray); |
|
| 132 | } |
|
| 133 | ||
| 134 | return $idarray; |
|
| 135 | } |
|
| 136 | ||
| 137 | //returns an array of ALL parent ids for a given id($sel_id) |
|
| 138 | ||
| @@ 146-162 (lines=17) @@ | ||
| 143 | * |
|
| 144 | * @return array |
|
| 145 | */ |
|
| 146 | public function getAllParentId($sel_id, $order = '', $idarray = array()) |
|
| 147 | { |
|
| 148 | $sel_id = (int)$sel_id; |
|
| 149 | $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $sel_id . ''; |
|
| 150 | if ($order != '') { |
|
| 151 | $sql .= " ORDER BY $order"; |
|
| 152 | } |
|
| 153 | $result = $this->db->query($sql); |
|
| 154 | list($r_id) = $this->db->fetchRow($result); |
|
| 155 | if ($r_id == 0) { |
|
| 156 | return $idarray; |
|
| 157 | } |
|
| 158 | array_push($idarray, $r_id); |
|
| 159 | $idarray = $this->getAllParentId($r_id, $order, $idarray); |
|
| 160 | ||
| 161 | return $idarray; |
|
| 162 | } |
|
| 163 | ||
| 164 | //generates path from the root id to a given id($sel_id) |
|
| 165 | // the path is delimetered with "/" |
|
| @@ 308-326 (lines=19) @@ | ||
| 305 | * |
|
| 306 | * @return array|unknown|unknown_type |
|
| 307 | */ |
|
| 308 | public function getAllChild($sel_id = 0, $order = '', $parray = array()) |
|
| 309 | { |
|
| 310 | $sel_id = (int)$sel_id; |
|
| 311 | $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . ''; |
|
| 312 | if ($order != '') { |
|
| 313 | $sql .= " ORDER BY $order"; |
|
| 314 | } |
|
| 315 | $result = $this->db->query($sql); |
|
| 316 | $count = $this->db->getRowsNum($result); |
|
| 317 | if ($count == 0) { |
|
| 318 | return $parray; |
|
| 319 | } |
|
| 320 | while ($row = $this->db->fetchArray($result)) { |
|
| 321 | array_push($parray, $row); |
|
| 322 | $parray = $this->getAllChild($row[$this->id], $order, $parray); |
|
| 323 | } |
|
| 324 | ||
| 325 | return $parray; |
|
| 326 | } |
|
| 327 | ||
| 328 | /** |
|
| 329 | * Enter description here... |
|