Welcome Guest, Not a member yet? Register   Sign In
question on MVC
#3

[eluser]Unknown[/eluser]
not really no.

Sorry if my english isn't very clear Smile i'm from a country you probably never heard off ^^

Basically, i've got 2 classes : User and Template.

in my "normal code" (read: without CI)

i read a given user_id, read it from db, read the template_id in the user's row.
then i create a new Template object with that template_id and i store the object's reference in the user object.

so from my main app, i can do $currUser->template->getVar();



Now my problem with CI and MVC, is that i now have a User Model and a Template model.


inside the user model object, i should create a new template object and store the reference in the user model object.
so i would have to do a :

$this->template = new Template($template_id);

but that's not very CI .. how would i go about doing that ?

Only way i found is doing :
$this->load->library('TemplateLib');
$this->template = TemplateLib;
$this->template->load($template_id);


But then if i get a 1-to-many relationship ? do i do these three lines in a loop ?
Is there no other way to instantiate objects in CI ???


Messages In This Thread
question on MVC - by El Forum - 12-17-2007, 04:22 AM
question on MVC - by El Forum - 12-17-2007, 02:00 PM
question on MVC - by El Forum - 12-18-2007, 01:45 AM
question on MVC - by El Forum - 12-18-2007, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB