Welcome Guest, Not a member yet? Register   Sign In
Modelling Questions
#1

[eluser]dreamnid[/eluser]
Hi all,

We want to rewrite our codebase from scratch using CI. However, I'm trying to figure out how to model our code into something that will work with CI.

Here is what I'm trying to do (written in Java):

Code:
public class Person {
   private int id;
   private String name;
   private String pass;
   private Pref pref;

   private String[] items;

   public Person( int id ) {
      // Get info from database based off id
   }

   //accessor functions
}

public class Pref {
   private boolean isActive;

   etc.
}


Code:
Person pers = new pers( 1 );
   if ( pers.getName() == "admin" )
   ...

I figured that in CI, Person would be a model. However, I found out you cannot pass parameters to the constructor of models.

Some possible solutions:
- Add another function to set the id
- Create the Person as its own class, but I would lose access to the database functions
- Modify the Model class

Is there should be a better way of doing this in CI?

Thanks!


Messages In This Thread
Modelling Questions - by El Forum - 11-29-2007, 12:14 PM
Modelling Questions - by El Forum - 11-29-2007, 01:44 PM
Modelling Questions - by El Forum - 12-01-2007, 10:19 AM
Modelling Questions - by El Forum - 12-01-2007, 11:35 PM
Modelling Questions - by El Forum - 12-02-2007, 09:42 PM
Modelling Questions - by El Forum - 12-02-2007, 11:40 PM
Modelling Questions - by El Forum - 12-03-2007, 12:28 AM
Modelling Questions - by El Forum - 12-04-2007, 07:55 PM
Modelling Questions - by El Forum - 12-04-2007, 11:11 PM
Modelling Questions - by El Forum - 12-04-2007, 11:55 PM
Modelling Questions - by El Forum - 12-05-2007, 12:39 AM
Modelling Questions - by El Forum - 11-30-2008, 07:11 AM
Modelling Questions - by El Forum - 11-30-2008, 11:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB