Casting in Entity Classes |
If you use JSON column in database, you must use JSON cast in entity.
If you use TEXT (VARCHAR) column in database, you can use ARRAY cast in entity. You do not need to unserialize object from database yourself. It will be automagically converted to array once entity is loaded through model from database. From my experience, if you use your own serialized object and save in database manually, most probably ARRAY cast will not be able to convert it to php array as you expect. Instead, always load new entity, fill variable as php array and save entity through model in database, then serialised object will be correct to retrieve it back as array. Entity serialize is not exactly the same as simple php array serialize. You can follow the system code to investigate yourself. |
Messages In This Thread |
Casting in Entity Classes - by groovebird - 12-14-2024, 05:14 AM
RE: Casting in Entity Classes - by davis.lasis - 12-14-2024, 11:31 AM
RE: Casting in Entity Classes - by groovebird - 12-14-2024, 12:03 PM
|