Kcko
10/28/2016 - 7:31 AM

From https://forum.nette.org/cs/20267-jde-nejak-zmenit-data-v-active-row-kdyz-jsou-ted-read-only#p139460 Wrapper nad ActiveRow, Nette

class RowWrapper extends Nette\Object
{
    protected $row;

    protected $data;

    public function __construct(Nette\Database\Table\ActiveRow $row)
    {
        $this->row = $row;
    }

    public function &__get($key)
    {
        if(isset($this->data[$key]) {
            $value = $this->data[$key];
        }
        $value = $this->row->$key;

        return $value;
    }

    public function __set($key, $value)
    {
        $this->data[$key] = $value;
    }

    //pripadne jeste related a ref

}