Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter best practice?
#1

[eluser]Unknown[/eluser]
Hello all,

I'm new to using CodeIgniter and have a general question about how classes should be used.

In my head, I'd like to have a User class with lots of getters and setters, and then create and populate a user object to pass to the view. The view could then have in it code such as:

Code:
Hello, <?php echo($user->get_name()); ?>

However, I'm not sure this fits in with the CodeIgniter model. Should the user class simply be a model? How would I then send the object to the view, would it be like so:

Code:
$this->load->model('User');
$this->user->create_from_id(123);
$data['user'] = $this->user;

Just kind of speaking out loud here, but wanted to get an idea if this sort of approach fits in with the CodeIgniter ethos?




Theme © iAndrew 2016 - Forum software by © MyBB