- $sql = "SELECT $this->nombre, $this->id
- FROM $this->tabla
- WHERE $this->padre = '$id'";
+ $sql = "SELECT $this->nombre, $this->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;