Welcome Guest, Not a member yet? Register   Sign In
Just what is a "Model" supposed to be in CI?
#1

[eluser]Chrisbloom7[/eluser]
I've been developing with PHP for going on 7 years now. About a year ago I started to dabble with Ruby on Rails, and though I liked the idea of the framework and what it could do, I was not at all comfortable with the Ruby language itself nor with some of the limitations that "convention over configuration" imposed, so I came back to PHP. I'm now playing around with CI as it seems to give me a lot of the useful features that I really enjoyed in Rails and with a very minimal code base.

One question I have at the moment is what is a "Model" to CI? Technically, a model is a representation of some data object, like a user, a blog post, a car, etc. However, of all of the examples that I've seen in the video tutorials and in the CI documentation a model is treated more like a container for some helper functions - there is no OO programming going on.

Ideally, I would like my models to be ORMed so that I could create an instance of a model and work on it directly, as well as add in validation, getters and setters, and other abstracted functions. As I understand it now, the only way to do access data in CI is to use the Database class to grab the data from the database, but the data itself (from the result() function) is an array, not an object. Even the supplied Active Record class doesn't really have anything to do with OO at all. It appears to be just another database abstraction layer.

Am I missing something that I could be doing to reach this result? Or am I misunderstanding what CI is using models for?

It seems like the real way to go might be to extend the Database class for each object I want to model, but then what do I lose out on if I'm not using the Model class? And how to I load my new Database classes?


Messages In This Thread
Just what is a "Model" supposed to be in CI? - by El Forum - 05-01-2009, 03:02 PM
Just what is a "Model" supposed to be in CI? - by El Forum - 05-03-2009, 05:22 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 05-03-2009, 07:11 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 05-03-2009, 07:17 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 08-19-2009, 07:53 PM
Just what is a "Model" supposed to be in CI? - by El Forum - 08-20-2009, 05:47 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 08-20-2009, 06:25 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 07:42 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 07:46 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 07:53 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 09:12 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 09:45 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 09:56 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 10:07 AM
Just what is a "Model" supposed to be in CI? - by El Forum - 09-29-2009, 11:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB