[eluser]Joakim_[/eluser]
Hello. I trying to figure out what's wrong with my model function. The function works if I replace the database stuff with a echo. It also works if I put the Active Records code directly in the Controller. Any help are very appreciated, thanks!
Code:
<?php
class Item_model extends Model {
function Item_model()
{
parent::Model();
}
function get_items()
{
$this->db->select('*');
$this->db->from('items');
$this->db->where('items.id', $this->uri->segment(3));
$this->db->join('clients', 'clients.id = items.item_client');
return $this->db->get();
}
}
?>
Here is the Controller
Code:
function item()
{
$this->load->model('item_model','model');
$data ['query'] = $this->model->get_items();
$this->load->view('items/item', $data);
}
The view file have this php:
Code:
<?php if ($query->num_rows() > 0): ?>
<?php foreach($query->result() as $item): ?>
//Content here
<?php endforeach; ?>
<?php endif; ?>