Esto estaria bien?
Código PHP:
class conectarBD{
var $servidor;
var $usuario;
var $password;
function __construct($servidor,$usuario, $password){
$this->servidor=$servidor;
$this->usuario=$usuario;
$this->password=$password;
}
function conectar(){
$conexion= mysql_connect($this->servidor, $this->usuario, $this->password);
mysql_select_db ("basededatos", $conexion);
}
}
//Para conectarnos a la base de datos
$conect = new conectarBD("localhost", "root", "");
$conect->conectar();
class modificarBD{
var $tabla;
var $values;
var $campos;
var $ordenar;
function __construct($tabla,$where,$values,$campos,$ordenar){
$this->tabla=$tabla;
$this->values=$values;
$this->campos=$campos;
$this->where=$where;
$this->ordenar=$ordenar;
}
function insertar(){
$add= "insert into $this->tabla $this->campos values $this->values";
}
function consultar(){
$registros= mysql_query("SELECT $this->tabla FROM $this->campos WHERE $this->where='$this->values' $this->ordenar ", $conexion) or die (mysql_error ());
}
function modificar(){
$edit = mysql_query("UPDATE `basededatos`.`usuarios` SET `nombre` = \'nombre\' WHERE `usuarios`.`id_usuario` = 25;", $conexion) or die (mysql_error ());
}
}