Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can I skip Model event

Hi everyone. Does Phalcon provide any proper way to skipping Model event?

So, I want to call $entity_instance->update(); without firing beforeUpdate()



62.9k
edited Jul '17

i cant remember if there was a native way of doing it

but ..

$model->_skipMe = true;
$model->update(); // public function ... { if $this->_skipMe === true $this->skipMe = false; return true  }

Thanks! That's what I was looking for!

But imagine my operation will be delete() instead of update() and my model has Soft Delete Behaviour and at the same time I need to skip beforeUpdate()

    Model::setup([
        'events' => false,
    ]);
    $entity_instance->delete();

It canceled events and record will be removed from db instead of marked as archived Is there any native way out?

edited Jul '17

I don't think so. In that case you need to do update, changing value of flag column.