Welcome Guest, Not a member yet? Register   Sign In
SOLVED: What's wrong with my model?
#1

[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; ?>
#2

[eluser]wiredesignz[/eluser]
I don't think alias name `model` is acceptable to CI
#3

[eluser]Joakim_[/eluser]
[quote author="wiredesignz" date="1213637468"]I don't think alias name `model` is acceptable to CI[/quote]

Thank you! That solved the problem! Smile




Theme © iAndrew 2016 - Forum software by © MyBB