Code Duplication    Length = 17-19 lines in 3 locations

class/xoopstubetree.php 3 locations

@@ 117-135 (lines=19) @@
114
     *
115
     * @return array
116
     */
117
    public function getAllChildId($sel_id, $order = "", $idarray = array())
118
    {
119
        $sel_id = intval($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
    /**
@@ 145-161 (lines=17) @@
142
     *
143
     * @return array
144
     */
145
    public function getAllParentId($sel_id, $order = "", $idarray = array())
146
    {
147
        $sel_id = intval($sel_id);
148
        $sql    = "SELECT " . $this->pid . " FROM " . $this->table . " WHERE " . $this->id . "=" . $sel_id . "";
149
        if ($order != "") {
150
            $sql .= " ORDER BY $order";
151
        }
152
        $result = $this->db->query($sql);
153
        list ($r_id) = $this->db->fetchRow($result);
154
        if ($r_id == 0) {
155
            return $idarray;
156
        }
157
        array_push($idarray, $r_id);
158
        $idarray = $this->getAllParentId($r_id, $order, $idarray);
159
160
        return $idarray;
161
    }
162
163
    //generates path from the root id to a given id($sel_id)
164
    // the path is delimetered with "/"
@@ 310-328 (lines=19) @@
307
     *
308
     * @return array
309
     */
310
    public function getAllChild($sel_id = 0, $order = "", $parray = array())
311
    {
312
        $sel_id = intval($sel_id);
313
        $sql    = "SELECT * FROM " . $this->table . " WHERE " . $this->pid . "=" . $sel_id . "";
314
        if ($order != "") {
315
            $sql .= " ORDER BY $order";
316
        }
317
        $result = $this->db->query($sql);
318
        $count  = $this->db->getRowsNum($result);
319
        if ($count == 0) {
320
            return $parray;
321
        }
322
        while ($row = $this->db->fetchArray($result)) {
323
            array_push($parray, $row);
324
            $parray = $this->getAllChild($row[$this->id], $order, $parray);
325
        }
326
327
        return $parray;
328
    }
329
330
    /**
331
     * Enter description here...