Welcome Guest, Not a member yet? Register   Sign In
ORM-like model implementation in CI
#1

[eluser]bAum[/eluser]
Hi all,

I am new to CI, and I was wondering what the general approach is to implement models that represent database records in CI.

In my understanding, CI models as they are presented in the user guide, for instance, are not a representation of some database record, but rather of a whole concept (the user guide contains the example of a "blog", not of a "blog post"). And there is the fact that CI's default behavior when loading a model is to create a single instance of that model having the model's name. This also suggests that the intent is to create a model once, like some data-oriented library.

I prefer, however, the orm/activerecord approach, where a model instance represents some record of my database, which means that I'll generally deal with several instances of the same model. Yet, as far as I understand, all loaded models are part of the CI namespace, and if I load a model twice with the same name (just imagine a loop over blogposts, for each one I would load a blogpost model which I call temp), I'll get an error that I'm using a name that already exists.

This naming conflict was just an example, I'm sure that this is not the only issue I'll have to deal with. So what would people here suggest me? How would you implement this stuff in CI (well, I could create model classes not "linked" to CI, but this would somehow undermine CI)?

Many thanks.


Messages In This Thread
ORM-like model implementation in CI - by El Forum - 08-09-2007, 02:24 AM
ORM-like model implementation in CI - by El Forum - 08-09-2007, 09:15 AM
ORM-like model implementation in CI - by El Forum - 08-10-2007, 06:15 AM
ORM-like model implementation in CI - by El Forum - 08-11-2007, 02:56 AM
ORM-like model implementation in CI - by El Forum - 08-11-2007, 09:10 AM
ORM-like model implementation in CI - by El Forum - 08-11-2007, 06:50 PM
ORM-like model implementation in CI - by El Forum - 08-16-2007, 11:52 AM
ORM-like model implementation in CI - by El Forum - 08-16-2007, 02:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB