segun tu me tendria que quedar asi, no???
Código PHP:
Ver originalinclude('db.php');
class material extends DB{
private $db;
public $id;
public $nombre;
public $referencia;
public $peso;
public $tamano;
public function __construct($id_material){
if($id_material > 0){
$this->db = new DB();
$sql= "
SELECT
*
FROM material
WHERE id = ".$id_material."
";
$this->db->query = $sql;
$t_material = $this->db->AssocList();
foreach($t_material as $k => $v){
$this->id = $t_material[$k]['id'];
$this->nombre = $t_material[$k]['nombre'];
$this->referencia = $t_material[$k]['referencia'];
$this->peso = $t_material[$k]['peso'];
$this->tamano = $t_material[$k]['tamano'];
}
}
}
public function add($Idatos;)
{
$this->nombre = $Idatos['nombre'];
$this->referencia = $Idatos['referencia'];
$this->peso = $Idatos['peso'];
$this->tamano = $Idatos['tamano'];
;
$sql= "INSERT INTO material(nombre, referencia, peso, tamano)VALUES(".$this->nombre.", ".$this->referencia.", ".$this->peso.", ".$this->tamano.")" ;
$this->db->query = $sql;
$this->db->InsertData();
}
}
$material = new material(-1);
$material->add($Idatos);