From: Gonzalo Merayo Date: Mon, 14 Jul 2003 22:00:58 +0000 (+0000) Subject: Se agregan 2 nuevos campos a la configuracion: 'where' y 'order'. X-Git-Tag: svn_import~377 X-Git-Url: https://git.llucax.com/mecon/meconlib.git/commitdiff_plain/1f4058d316369bb276ce9976fe6681f23959a318 Se agregan 2 nuevos campos a la configuracion: 'where' y 'order'. 'where' permite agregar clausular WHERE arbitrarias (util para hacer JOIN). 'order' especifica si se quire ordenar ASC o DESC. Si se omite no se ordena. --- diff --git a/lib/MECON/HTML/Arbol/ArbolDB.php b/lib/MECON/HTML/Arbol/ArbolDB.php index 6937df8..0594bcb 100644 --- a/lib/MECON/HTML/Arbol/ArbolDB.php +++ b/lib/MECON/HTML/Arbol/ArbolDB.php @@ -13,6 +13,8 @@ class HTML_ArbolDB extends HTML_Arbol var $id; var $link = null; var $prepend_link = null; + var $where = ''; + var $order = ''; var $db; function HTML_ArbolDB($dbdata, $imagen) @@ -26,6 +28,10 @@ class HTML_ArbolDB extends HTML_Arbol $this->prepend_link = $dbdata['prepend_link']; if(isset($dbdata['link'])) $this->link = $dbdata['link']; + if(isset($dbdata['where'])) + $this->where = $dbdata['where']; + if(isset($dbdata['order'])) + $this->order = ' ORDER BY '.$dbdata['nombre'].' '.$dbdata['order']; $this->db = $dbdata['db']; $dat = $this->BuscarHijos(0); parent::HTML_Arbol($dat, $imagen); @@ -34,15 +40,22 @@ class HTML_ArbolDB extends HTML_Arbol function BuscarHijos($id) { $sql = "SELECT $this->nombre, $this->id "; - if(!is_null($this->link)) - $sql .= ", $this->link "; - $sql .= "FROM $this->tabla "; - if(!is_null($this->padre)) - $sql .= "WHERE $this->padre = '$id'"; + if(!is_null($this->link)) + $sql .= ", $this->link "; + $sql .= "FROM $this->tabla "; + if(!is_null($this->padre) or $this->where) + $sql .= 'WHERE '; + if(!is_null($this->padre)) { + $sql .= "$this->padre = '$id'"; + if ($this->where) + $sql .= ' AND'; + } elseif ($this->where) + $sql .= $this->where; + $sql .= $this->order; $result = $this->db->query($sql); if(DB::isError($result)) die($result->getMessage()); - $dat = array(); + $dat = array(); while($row = $result->fetchRow()) { $titulo = $row[0];