CodeIgniter Forums
why does Entity::fill() only accept arrays? - 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: why does Entity::fill() only accept arrays? (/showthread.php?tid=80888)



why does Entity::fill() only accept arrays? - lukmim - 12-30-2021

is there any particular reason Entity::fill() is made to only accept arrays but not objects?
it seems to me it should be possible to fill an entity from an object (for example when data is sent via API in a json) by iterating through its properties
otherwise I have to do $myEntity->fill((array)$objectData);


RE: why does Entity::fill() only accept arrays? - iRedds - 12-30-2021

PHP Code:
$myEntity->fill($request->getJSON(true));