Welcome Guest, Not a member yet? Register   Sign In
getCustomResultObject() bypasses my custom __set() method
#4

The __set method will not be called when filling with data from the database. 
PHP Code:
class Job
{
    protected $id;
    protected $name;
    protected $description;
    protected $demo = 'test';

    public function __get($key) {}

    public function __set($key, $value) {}
}
  

The __set method will be called when filling with data from the database.
But anymore it (and __get too) will not be called, because automatically created properties will have public visibility
PHP Code:
class Job
{
    public function __get($key) {}
    public function __set($key, $value) {}
}
  

This is not a framework problem. This is how the php + php-mysqli extension works.

A simple solution.

PHP Code:
class Job
{
    protected  $attributes = [];

    public function __get($key)
    {
        return $this->attributes[$key] ?? null;
    }

    public function __set($key$value)
    {
        $this->attributes[$key] = $value ' intercepted';
    }

Reply


Messages In This Thread
RE: getCustomResultObject() bypasses my custom __set() method - by iRedds - 01-31-2021, 08:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB