Questions tagged [before-save]

An ActiveRecord callback that is executed after validating an object but before writing it to the database.

before_save is one of the standard ActiveRecord callbacks. There are three sets of callbacks:

  • Creating an Object (in order of execution):
    1. before_validation
    2. after_validation
    3. before_save
    4. around_save
    5. before_create
    6. around_create
    7. after_create
    8. after_save
  • Updating an Object (in order of execution):
    1. before_validation
    2. after_validation
    3. before_save
    4. around_save
    5. before_update
    6. around_update
    7. after_update
    8. after_save
  • Destroying an Object (in order of execution):
    1. before_destroy
    2. around_destroy
    3. after_destroy
154 questions
-1
votes
1 answer

How to properly use and override beforeSave method in Yii2

I have override the existing \yii\db\ActiveRecord with my own class. The method I've override is beforeSave(). I've read the documentation about the usage. But I found it's called twice when checking the record whether it is a new record or not.…
-1
votes
2 answers

Yii check scenario in beforeSave()

For one action I need transform $album_id before save it to DB in model function beforeSave() i do: // преобразовать album -> album_id $album_id=array(); foreach($this->string2array($this->album, '\|') as $one) …
almix
  • 289
  • 1
  • 8
  • 21
-2
votes
1 answer

Phalcon BeforeSave not receiving data before saving?

Before I save my model, I would like to check if $ CONT_CEDULA meets the requirements. If not, then don't save. But when saving, it is as if the variable $ CONT_CEDULA hasn't got any data. I want to know if I'm doing well or need some other event or…
-2
votes
1 answer

How to display request data in cakephp beforesave method in model

I tried to display request data using $this->data in beforeSave method. But , i don't know why the method is not being called. How can I display posted data in beforeSave method in cakephp model?
fayaz
  • 1
1 2 3
10
11