Ipl/orm PropertyModifiers on update/insert

Hi,

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();
        if($asTransaction){
            $db->beginTransaction();
        }
        $this->beforeSave($db);
        $behavior = new Behaviors();
        $this->createBehaviors($behavior);
        $behavior->persist($this);

        $values=$this->getValues();

        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]);
        }
        if($asTransaction){
            $db->commitTransaction();
        }

    }

Thanks in advance and

Best Regards
Nicolas

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?
Thanks