Código PHP:
Ver original<?php
class Encapulador
{
private $mysqli = null;
private $stmt = null;
private $oneRef = 3;
public function __construct()
{
$this->mysqli = new mysqli('localhost', 'root', '', 'prueba');
$this->stmt = $this->mysqli->prepare("SELECT * FROM `items` WHERE `nro-i` = ?;");
$this->stmt->bind_param('i', $this->oneRef);
}
public function setVal($val)
{
$this->oneRef = $val;
}
public function execute()
{
$this->stmt->execute();
$registros = $this->stmt->get_result();
while($registro = $registros->fetch_array(MYSQLI_ASSOC))
}
}
$test = new Encapulador();
$a = 2;
$test->setVal($a);
$test->execute();
echo('<hr>');
$a = 5;
$test->setVal($a);
$test->execute();
echo('<hr>');
$a = 13;
$test->setVal($a);
$test->execute();
echo('<hr>');
EDITO: YA LO SOLUCIONE