On model level, we can always encrypt value in function beforeSave, but i don't know how to make fetch in the same way, so when i fetch data, there are automatilcy AES_DECRYPT. I want to do this without phsql.
public function beforeSave(){
$this->name = new RawValue('AES_ENCRYPT("'.$this->name.'", "secret_pass")');
}
So when i do this, it's work properly, so name is encrypted in blob field in database
$model = new Model();
$model->name = "abc";
$model->save();
but i don't know how to fetch unencrypted data directly from model, similar to this:
$data = Model::findFirst();
or
$data = Model::find();