Question

I was checking the API and noticed that there are _preSave and _postSave protected methods that could be used as hooks. Is there something similar for update/delete?

I was thinking of the following

preSave -> fires before a Save (insert/update)
postSave -> fires after a Save (insert/update)
preInsert
postInsert
preUpdate
postUpdate
preDelete
postDelete

Any existing functionality that I can use?

Was it helpful?

Solution

Compatible with version 0.4.5

In PhalconPHP these hooks are effectively validation events.

class Robots extends Phalcon_Model_Base
{
    function beforeSave()
    {
        if ($this->year < 0) {
            echo "Year cannot be negative";
            return false;
        }
    }
}

More information about validators

http://docs.phalconphp.com/en/latest/reference/models.html#validation-messages

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top