Welcome Guest, Not a member yet? Register   Sign In
first noob question (models)

[eluser]Xavier D.[/eluser]

I just started 2 hours ago with ci, it seems to be a great platform.

I've already tested several things, but now i'm having troubles with models.

// controller

class Test extends Controller {

    function Test()
    function index()
        $data['query'] = $this->Test_model->get_cld();
        $data['title']      = "Welcome bij cld";
        $data['heading'] = "Eerste ci project";
        $data['message'] = "Ci lijkt me een heel interessant gegeven :)";
        $this->load->view('includes/header', $data);
        //$this->load->view('test_view', $data);
        $this->load->view('test_view', $data);
// models

class Test_model extends Model {

        var $title   = '';
        var $message = '';
        var $date    = '';

        function Test_model()
            // Call the Model constructor
        function get_cld()
            $query = $this->db->get('cld');
            return $query->result();


<h1>&lt;?php echo $title ?&gt;</h1>
<p>&lt;?php echo $message ?&gt;</p>
&lt;?php foreach($query->related as $row): ?&gt;

<p>Datum: &lt;?=$row->date?&gt;</p>

&lt;?php endforeach;?&gt;

What am i doing wrong, calling the database in the controller works fine, but the moment i want to use modelsthe problem started ..

Also scaffolding is working fine.

error: Call to a member function get() on a non-object in /home/***/domains/***/public_html/cld/system/application/models/test_model.php on line 15

Is the active record setting in the config/database.php true?

[eluser]Xavier D.[/eluser]
Thx for the fast reply,

the AR is set to true

$active_record = TRUE;

$query = $this->db->query('select * from cld');

in the models page(same problem)

error: Call to a member function query() on a non-object

[eluser]Xavier D.[/eluser]
Problem solved.

$autoload['libraries'] = array();

must be

$autoload['libraries'] = array('database');

try this

[eluser]Xavier D.[/eluser]
[quote author="xwero" date="1218216514"]try this

Is also working, there was a load problem then.

thx for the support

Theme © iAndrew 2016 - Forum software by © MyBB