public function add(WaxModel $model) { $this->load(); //reassigning so that changes in the model reflect correctly foreach ($this as $index => $row) { if ($row->{$model->primary_key} && $row->{$model->primary_key} == $model->pk()) { $reassign = $index; } } if ($reassign) { $this->rowset[$reassign] = new WaxModelProxy($model); } else { $this->rowset[] = new WaxModelProxy($model); } }