Por ejemplo hago una consulta por id, pero al momento de solicitar el metodo getId() no contiene nada, sino que el dato se va a la funcion getId_Persona ya echo varias pruebas y no consigo solucionar
Código PHP :
class Productos {
private $id;
private $id_persona;
private $tipo_persona;
private $nombre;
private $descripcion;
private $presentacion;
private $c_barra;
private $anexo_cbarra;
private $ruta_barra;
private $tabla;
private $ruta_tabla;
private $registro_m;
private $anexo_registro;
private $ruta_registro;
const Tabla = 'productos';
public function getId() {
return $this->id;
}
public function getId_persona() {
return $this -> id_persona;
}
public function getPersona() {
return $this -> tipo_persona;
}
public function getNombre() {
return $this -> nombre;
}
public function getDescripcion() {
return $this -> descripcion;
}
public function getPresentacion1() {
return $this -> presentacion;
}
public function getC_barra() {
return $this -> c_barra;
}
public function getAnexo_barra() {
return $this -> anexo_cbarra;
}
public function getRuta_barra() {
return $this -> ruta_barra;
}
public function getTabla() {
return $this -> tabla;
}
public function getRuta_tabla() {
return $this -> ruta_tabla;
}
public function getRegistro_m() {
return $this -> registro_m;
}
public function getAnexo_registro() {
return $this -> anexo_registro;
}
public function getRuta_registro() {
return $this -> ruta_registro;
}
/*Metodo SET*/
public function setId_persona($id_persona){
$this -> id_persona = $id_persona;
}
public function setPersona($tipo_persona){
$this -> tipo_persona = $tipo_persona;
}
public function setNombre($nombre){
$this -> nombre = $nombre;
}
public function setDescripcion($descripcion){
$this -> descripcion = $descripcion;
}
public function setPresentacion($presentacion){
$this -> presentacion = $presentacion;
}
public function setC_barra($c_barra){
$this -> c_barra = $c_barra;
}
public function setAnexo_barra($anexo_cbarra){
$this -> anexo_cbarra = $anexo_cbarra;
}
public function setRuta_barra($ruta_barra){
$this -> ruta_barra = $ruta_barra;
}
public function setTabla($tabla){
$this -> tabla = $tabla;
}
public function setRuta_tabla($ruta_tabla){
$this -> ruta_tabla = $ruta_tabla;
}
public function setRegistro_m($registro_m){
$this -> registro_m = $registro_m;
}
public function setAnexo_registro($anexo_registro){
$this -> anexo_registro = $anexo_registro;
}
public function setRuta_registro($ruta_registro){
$this -> ruta_registro = $ruta_registro;
}
public function __construct($id_persona = null, $tipo_persona = null, $nombre = null, $descripcion = null, $presentacion = null, $c_barra = null, $anexo_cbarra = null, $ruta_barra = null, $tabla = null, $ruta_tabla = null, $registro_m = null, $anexo_registro = null, $ruta_registro = null,$id = null){
$this->id_persona = $id_persona;
$this->tipo_persona = $tipo_persona;
$this->nombre = $nombre;
$this->descripcion = $descripcion;
$this->presenacion = $presentacion;
$this->c_barra = $c_barra;
$this->anexo_cbarra = $anexo_cbarra;
$this->ruta_barra = $ruta_barra;
$this->tabla = $tabla;
$this->ruta_tabla = $ruta_barra;
$this->registro_m = $registro_m;
$this->anexo_registro = $anexo_registro;
$this->ruta_registro = $ruta_registro;
$this->id = $id;
}
public static function recuperarTodos($conexion) {
$conexion = new Conexion();
@mysqli_query($conexion, "SET NAMES 'utf8'");
$consulta = $conexion->prepare('SELECT * FROM ' . self::Tabla . ' ORDER BY id');
$consulta->execute();
$registros = $consulta->fetchAll();
$conexion = null;
return $registros;
}
public static function buscarPorId($conexion,$id) {
$consulta = $conexion->prepare('SELECT id,id_persona,tipo_persona,nombre,descripcion,presentacion,c_barra,anexo_cbarra,ruta_cbarra,tabla,ruta_tabla,registro_m,anexo_registro,ruta_registro FROM ' . self::Tabla . ' WHERE id = :id');
$consulta->bindParam(':id', $id);
$consulta->execute();
$registro = $consulta->fetch();
$conexion = null;
if ($registro) {
return new self($registro['id_persona'], $registro['tipo_persona'], $registro['nombre'], $registro['descripcion'], $registro['presentacion'], $registro['c_barra'], $registro['anexo_cbarra'], $registro['ruta_cbarra'], $registro['tabla'], $registro['ruta_tabla'], $registro['registro_m'], $registro['anexo_registro'], $registro['ruta_registro']);
} else {
return false;
}
}
public static function buscarPorId2($conexion,$id) {
$consulta = $conexion -> prepare('SELECT * FROM ' . self::Tabla . ' WHERE id = :id');
$consulta->bindParam(':id', $id);
$consulta->execute();
$registro = $consulta->fetchAll();
$conexion = null;
return $registro;
}
public static function buscarPorId3($conexion,$id) {
$consulta = $conexion->prepare('SELECT id FROM ' . self::Tabla . ' WHERE id = :id');
$consulta->bindParam(':id', $id);
$consulta->execute();
$registro = $consulta->fetch();
$conexion = null;
if ($registro) {
return new self($registro['id'],$id);
} else {
return false;
}
}
}
?> 