'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.
var $id;
var $link = null;
var $prepend_link = null;
var $id;
var $link = null;
var $prepend_link = null;
+ var $where = '';
+ var $order = '';
var $db;
function HTML_ArbolDB($dbdata, $imagen)
var $db;
function HTML_ArbolDB($dbdata, $imagen)
$this->prepend_link = $dbdata['prepend_link'];
if(isset($dbdata['link']))
$this->link = $dbdata['link'];
$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);
$this->db = $dbdata['db'];
$dat = $this->BuscarHijos(0);
parent::HTML_Arbol($dat, $imagen);
function BuscarHijos($id)
{
$sql = "SELECT $this->nombre, $this->id ";
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());
$result = $this->db->query($sql);
if(DB::isError($result))
die($result->getMessage());
while($row = $result->fetchRow())
{
$titulo = $row[0];
while($row = $result->fetchRow())
{
$titulo = $row[0];