Welcome Guest, Not a member yet? Register   Sign In
Collections of models?
#1

[eluser]Unknown[/eluser]
I'm new to CI and have some prior experience of MVC. Say for example I have a model club, see pseudo code:

Code:
class Club {
  clubId = 1;
  name = "My Club"
  people = array();
}
Each club contais an array of people objects:

Code:
class Person {
  personId = 1;
  name = "Joe Bloggs"
  age = 23;
  gender = "male"
}

Normally I would have method of the Club class that loads the data from the database and creates an array (collection) of Person objects and then sets the properties of the Person objects based on the data in the DB.

Is this overkil or is there a better way to do this in CI?

My aim is to make the code as reusable as possible, and in the above example people belong to a club. Both people and clubs should have a view associated though there may not always be a view needed for each model.




Theme © iAndrew 2016 - Forum software by © MyBB