Welcome Guest, Not a member yet? Register   Sign In
What options are there for mapping relationships in Models/Entities
#1

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?   
Reply
#2

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.
Reply
#3

Thanks for the tip! CI4OrmExtension looks really promising.
Reply
#4

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?
Reply
#5

(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.
Reply
#6

Hello,

if you want use Doctrine with Codeigniter 4 you can use this library.

https://github.com/daycry/doctrine

Thannk you
Reply
#7

Has anyone here used the ORMExtension with success? I installed it and am having problems with some basics like getting it to save (insert) a new record and update an existing one. I'm using the principles demonstrated in the example files included with the package. I'm fully willing to believe that I'm getting something wrong, but ideally would like to hear from anyone who is using the package, either successfully or with difficulty.
Using Ci4ORMExtension 1.0 with CodeIgniter 4.3.2.
Thanks.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB