codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

Update trigger called before validate()

Open pickupman opened this issue 11 years ago • 0 comments
trafficstars

The trigger 'before_update' should be called after validation. Example: If you are trying to confirm a password field before update a record, validation will pass if you don't unset the confirm password field. However the update() will fail, as you have an extra column. If you unset the confirm field, validation will fail, as the field will not match.

In the update() and update_many() methods, the trigger('before_update') should be like:

if ($data !== FALSE)
        {
            $data = $this->trigger('before_update', $data);
            $result = $this->_database->where($this->primary_key, $primary_value)
                               ->set($data)
                               ->update($this->_table);

            $this->trigger('after_update', array($data, $result));

            return $result;
        }

This is the same place the before_insert trigger is called in the insert() method.

pickupman avatar Apr 13 '14 15:04 pickupman