A controller problem using a base CRUD model
- by rkj
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');
}