CodeIgniter Forums
Hasmany in CodeIgniter? - 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: Hasmany in CodeIgniter? (/showthread.php?tid=87415)



Hasmany in CodeIgniter? - sjender - 04-18-2023

Hi,
I was just wondering if there is the CI models support some kind of HASMANY or BELONGSTO functionality.
I recently touched a Laravel and CakePHP which both have this functionality.


RE: Hasmany in CodeIgniter? - iRedds - 04-18-2023

Relationships are not supported by default.
But you can try using the model extension. https://github.com/tattersoftware/codeigniter4-relations


RE: Hasmany in CodeIgniter? - kenjis - 04-18-2023

Another package:
https://github.com/michalsn/codeigniter-nested-model


RE: Hasmany in CodeIgniter? - sjender - 04-19-2023

I am wondering whether using a hasmany construction will slow down each query on that table since it will have to do a join for each select....

Wouldnt it be better/faster to have a method in the entity class which will get the child records? So you you will only have to query them on demand....