CodeIgniter Forums

Full Version: What options are there for mapping relationships in Models/Entities
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm taking a look at CI 4 and really enjoying it.  However, one thing that seems to be sorely missing is the ability to map relationships (One to Many, Many to Many, etc) within models and/or entities.  

I did find these two:

https://github.com/hlohrenz/CI4-Relation...ry-Builder  Appears to be stalled or abandoned

https://github.com/tattersoftware/codeig...-relations   This looks interesting, but documentation is scant and seems it only maps Many to Many?


Are there any other ones I'm missing? What options are currently available for this sort of ORM functionality, outside of using a separate library like doctrine, etc?   
This has been on my mind as well.

I did a search through Packagist and came across this: github.com/4spacesdk/CI4OrmExtension This seems like a great tool and has all the features you would need to maintain relationships between entities.

It kind mimics another great CI3 ORM tool written by Nick Tsai that you can find here: https://github.com/yidas/codeigniter-model

My favourite feature of both of these is that each entity has a built in $entity->save() function rather than having to load the model and pass the entity to save.
Thanks for the tip! CI4OrmExtension looks really promising.
My module (the second of your links) supports all relationship types, just some of the entity functions are specific to Many To Many.

What else would you like to see as far as docs?
(12-03-2019, 04:42 AM)MGatner Wrote: [ -> ]My module (the second of your links) supports all relationship types, just some of the entity functions are specific to Many To Many.

What else would you like to see as far as docs?

Ah, good to know! I'll definitely try it out.   As for the docs, I'd like to see examples illustrating the various types of relationships, handling bi directional relationships, etc, as this is what I sort of came in looking for.  The docs sort of have this now but IMHO it seems a bit terse and not real obvious what all the library does.  I'm still not real clear on how the schema module fits in to the picture.  An example illustrating this would be helpful.