![]() |
Insert Batch Using Entity Classes - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Insert Batch Using Entity Classes (/showthread.php?tid=90855) |
Insert Batch Using Entity Classes - warcooft - 05-13-2024 Hello admin @kenjis, Thank you for your hard work. I have a little problem, i tried to save several data using the entity class, but it turns out that only the first data is stored. How can I save several data at once, thank you for your attention here sample code: PHP Code: $users = auth()->getProvider(); RE: Insert Batch Using Entity Classes - kenjis - 05-14-2024 It seems you misunderstand Entities (or PHP objects). You created an User entity, and filled chairman's data. The $user object represents chairman. After saving it, you filled admin's data into chairman's object. And you saved it. That means you saved chairman's entity. If you want to use another User entity, create a new User entity with $user = new User(); RE: Insert Batch Using Entity Classes - warcooft - 05-14-2024 (05-14-2024, 02:44 AM)kenjis Wrote: It seems you misunderstand Entities (or PHP objects). I think there is a simpler way apart from creating a new entity object. Thanks for quick response. |