Entity Property cast as array not autoserializing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Entity Property cast as array not autoserializing (/showthread.php?tid=76228) |
Entity Property cast as array not autoserializing - kloukas - 04-23-2020 Hi, I'm trying to cast an entity property into an array so that it autoserializes. I'm using the constructor to fill the properties as follows PHP Code: <?php Dumping the submission at this point (var_dump()) shows field2 being an array, it's not serialised. Code: ["attributes":protected]=> if I do PHP Code: $allowedFromPost = [ Code: ["attributes":protected]=> For some reason, it seems like filling using the constructor does not autoserialize, I have to manually set the field. Am I doing something wrong? The problem this caused is that when I tried insterting that into the Database, it threw an error saying "mysqli_sql_exception Operand should contain 1 column(s)" which went away when I flattened the array (first by dropping all but one values to test and then by using what I've done above) |