Código PHP:
class db {
var $tablas = array();
var $campos = array();
var $valores = array();
function db ($in_tablas, $in_campos) {
$this->tablas = $in_tablas;
$this->campos = $in_campos;
function insert{
$sql = 'INSERT INTO '. implode(',',$this->tablas) .'('.
implode(',',$this->campos). ' VALUES(' . implode(',',$this->valores).')';
return mysql_query($sql)
}
function set($in) {
$this->valores = $in;
}
class cliente{
var db;
var nombre;
var apellido;
function cliente {
$tabla = array ('T_Customer');
$campos = array ('Name','SurName');
$this->db = &new db($tabla,$campos);
}
function insertar {
$this->db->set(array($this->nombre,$this->apellido)
return $this->db->insert;
}
funcrion set($in){
if (in_array('nombre',$in)) $this->apellido=$in['nombre'];
if (in_array('apellido',$in)) $this->apellido=$in['apellido'];
}
$cliente = &new cliente;
$cliente->set(array('nombre'=>'JM');
$cliente->insertar;