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

[eluser]dreamnid[/eluser]
Hi again,

Thanks for your replies.

The way I want to model the Person is you instantiate a person with a specific id. Then you can get attributes of the Person for that specific person.


For example:
Code:
$person = new Person( 32 );
echo $person->getId( );
echo $person->getEmail( );
echo $person->getWebsite( )->getTitle( );  // Get the website for the person and print out the title
Again, the last line is based off what I did in Java in one of my classes which I'm not sure how to translate it into CI.

From what I'm read so far, it seems that CodeIgnitor wants the id as a parameter to the member function, such as
Code:
$this->load->model('Person');
$this->model->getEmail( 32 );
$this->model->getWebsite( 32 )->getTitle()  // Not sure how this would work

To me, this requires each get function to make a different database call for each parameter that we're retrieving which adds overhead. Am I understanding this correctly?

For now, I've being creating the Person class as a library which seems to work okay, but I'm sure it is not ideal practice.

I'm trying to find other people's models to see what is supposed to be in a model and how they avoid querying the database for each parameter.

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