![]() |
changing model data before returning it? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: changing model data before returning it? (/showthread.php?tid=84912) |
changing model data before returning it? - rramsey - 11-22-2022 I have a basic People table with name, created_at, updated_at, and deleted at columns. I have People Entity and PeopleModel classes set up correctly(I think). In my controller I do: PHP Code: public function getPeople() { Code: "created_at": { What I want is just the simple datetime value: "created_at": "2022-11-22 08:55:22" not an object. The db doesn't store milliseconds either and I'm not using them. I've tried a getter in the Entity because it wasn't 100% clear the getter only fired if I tried to get the value outside of the model. I tried setting up an afterFind callback modeled after the beforeFind in the docs, but the data didn't really fit the example. I tried PHP Code: if (isset($data['name']) ) { And a few more variations, but no luck. Is there a built-in way to get back: Code: { Thanks! |