I'm trying to do a class to connect to the database using mysqli, from this class, I inherit other class who call a method to do a query. Here part of the class:
protected $conn;
protected $stmt;
protected $reflection;
protected $sql;
public function connect() {
$this->conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
}
protected function prepare_query() {
$this->stmt = $this->conn->prepare($this->sql);
$this->reflection = new ReflectionClass('mysqli_stmt');
}
protected function set_params() {
$method = $this->reflection->getMethod('bind_param');
$method->invokeArgs($this->stmt, $this->data);
}
public function execute() {
$this->connect();
$this->prepare_query();
$this->set_params();
$this->stmt->execute();
}
I send the array with the arguments, without problem. But... then I get this error: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given I can see when I use the debugger, the array is ok, the query is ok. So, what I'm doing wrong?
Greetings from CO