Welcome Guest, Not a member yet? Register   Sign In
I need a supermodel. :)
#1

[eluser]behdesign[/eluser]
I'm puzzled about what exactly I need in order to fit my application. I'm diligently creating models that handle the database, but I have need of some sort of ... 'controller' - for lack of a better word. A traffic-cop object. Let me explain a bit further.

The project presents lessons for users, so there are text Q&A quizzes and other verification methods, each of which is tied to a different model. What I need is some object to tie all of these together - a Proctor class. It decides what kind of test to administer, determines whether the user passes, moves the user to the next lesson, etc. Lessons, Classes, Tests, Users ... all models. I need something to handle the interactions between these models that isn't necessarily going to be a controller - after all, I don't want the users hitting the /proctor URI - that breaks the idea of controller.

It could be a helper, but that seems to be backwards - calling the Proctor from inside the individual objects. So am I looking at a library? I've looked at a few of the ORM and HMVC solutions, and it seems like a whole lot of bulk to add (and understand) for what I would think is a rather simple piece of control code.

Suggestions?
#2

[eluser]tomcode[/eluser]
You can create a MY_Model library which extends the core Model library, every Model loaded will extend it.

file application/libraries/MY_Model.php :
Code:
class MY_Model extends Model {

    function MY_Model()
    {
        parent::Model();
    }
}

Edit :
Extending Models :
Code:
class Extending_model extends MY_Model {

    function Extending_model() {

        parent::MY_Model();
    }
}
#3

[eluser]JoostV[/eluser]
A base model could be a good idea. If you need more loose coupling you could create a proctor library. By using a library the proctor code would be separated from your models, instead of being part of it.
#4

[eluser]behdesign[/eluser]
The problem with extending all models is that all models don't descend from, or need, Proctor (the ecommerce section, for example). I suppose I could extend the base Model for each super-model I need, then descend from those, but that seems like a rather large tangle. I'm going to go with a library for now, and hope for better ORM libraries in the future.

I personally think that ORM is the last bit that separates CI from being as top-notch as Rails. Well, that and CI is a bazillion times easier to deploy. Smile
#5

[eluser]JoostV[/eluser]
Of course, you do not have to extend the base model in every model Smile




Theme © iAndrew 2016 - Forum software by © MyBB