A controller problem using a base CRUD model
Posted
by rkj
on Stack Overflow
See other posts from Stack Overflow
or by rkj
Published on 2010-03-20T18:51:49Z
Indexed on
2010/03/20
19:01 UTC
Read the original article
Hit count: 332
codeigniter
|php
In CodeIgniter I'm using a base CRUD My_model, but I have this small problem in my browse-controller.. My $data['posts'] gets all posts from the table called "posts". Though the author in that table is just a user_id, which is why I need to use my "getusername" function (gets the username from a ID - the ID) to grab the username from the users table. Though I don't know how to proceed from here, since it is not just one post. Therefore I need the username to either be a part of the $data['posts'] array or some other smart solution.
Anyone who can help me out?
function index() {
$this->load->model('browse_model');
$data['posts'] = $this->browse_model->get_all();
$data['user'] = $this->browse_model->getusername(XX);
$this->load->view('header');
$this->load->view('browse/index', $data);
$this->load->view('footer');
}
© Stack Overflow or respective owner