Ipl/orm PropertyModifiers on update/insert


I would like to know if there is any example how to use the ipl/orm PropertyModifiers on insert / update.

Every example of update/insert always circumvents any modifier.

Would that be a vaild approach?

    public function save($asTransaction = true)

        $db = Database::get();
        $behavior = new Behaviors();


        if (!isset ($this->id) || $this->id === null) {
            $db->insert($this->getTableName(), $values);
            $this->id = $db->lastInsertId();

        } else {
            $db->update($this->getTableName(), $values, [$this->getKeyName().' = ?' => $this->id]);


Thanks in advance and

Best Regards

Yes. Because they’re not based on ipl\Orm, but ipl\Sql. And the latter has no such thing.

I don’t recommend it. We don’t use it ourselves that way either. Typically, data being used during an insert or update, comes from a form, which is then supposed to provide suitable values. No modifiers are needed then, besides some simple transformations if necessary. (like DateTime::format)

but why is there a toDb() if you won’t use it?

We use it. Just not for updating or inserting data. The method you linked is at the moment only used to transform values of filter expressions.

ahh so you transform the value for the filter to a Db compatible one in order to compare?