X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/46e1d55b1437c3eb73a9d877d9faae2979263639..6a5d60ab6ce03a168256c9b77ad1fd3166d50c14:/lib/MECON/HTML/Arbol/ArbolDB.php?ds=sidebyside diff --git a/lib/MECON/HTML/Arbol/ArbolDB.php b/lib/MECON/HTML/Arbol/ArbolDB.php index 6937df8..111c4e5 100644 --- a/lib/MECON/HTML/Arbol/ArbolDB.php +++ b/lib/MECON/HTML/Arbol/ArbolDB.php @@ -1,9 +1,31 @@ - +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ +require_once 'MECON/HTML/Arbol.php'; +require_once 'DB.php'; class HTML_ArbolDB extends HTML_Arbol { @@ -13,6 +35,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 +50,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 +62,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]; @@ -62,4 +97,5 @@ class HTML_ArbolDB extends HTML_Arbol } } + ?>