Code Duplication    Length = 18-18 lines in 2 locations

class/smarttree.php 2 locations

@@ 112-129 (lines=18) @@
109
     * @param  array  $idarray
110
     * @return array
111
     */
112
    public function getAllChildId($sel_id, $order = '', $idarray = array())
113
    {
114
        $sql = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
115
        if ($order != '') {
116
            $sql .= " ORDER BY $order";
117
        }
118
        $result = $this->db->query($sql);
119
        $count  = $this->db->getRowsNum($result);
120
        if ($count == 0) {
121
            return $idarray;
122
        }
123
        while (list($r_id) = $this->db->fetchRow($result)) {
124
            array_push($idarray, $r_id);
125
            $idarray = $this->getAllChildId($r_id, $order, $idarray);
126
        }
127
128
        return $idarray;
129
    }
130
131
    //returns an array of ALL parent ids for a given id($sel_id)
132
    /**
@@ 329-346 (lines=18) @@
326
     * @param  array  $parray
327
     * @return array
328
     */
329
    public function getAllChild($sel_id = 0, $order = '', $parray = array())
330
    {
331
        $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . '';
332
        if ($order != '') {
333
            $sql .= " ORDER BY $order";
334
        }
335
        $result = $this->db->query($sql);
336
        $count  = $this->db->getRowsNum($result);
337
        if ($count == 0) {
338
            return $parray;
339
        }
340
        while ($row = $this->db->fetchArray($result)) {
341
            array_push($parray, $row);
342
            $parray = $this->getAllChild($row[$this->id], $order, $parray);
343
        }
344
345
        return $parray;
346
    }
347
348
    /**
349
     * @param  int    $sel_id