Answer the question
In order to leave comments, you need to log in
How to process binary in model in yii2?
I want to store binary in the database, and work in the application as with a regular field. There is an idea to do transparent processing in beforeSave, but this does not look like a good solution because there is direct access to the field through the class, because there is a load method that will overwrite the field.
You need literally the following:
db (binary) <=> model (binary <=> text) <=> text.
What is the best way to do this transformation and where?
Answer the question
In order to leave comments, you need to log in
This task also hurt for a long time, as a result, it was decided through afterfind and insertInternal / updateInternal. Moreover, in insertInternal / updateInternal it is better not to modify the data through hex2bin, but to insert virtual changed values into the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question