[eluser]Xavier D.[/eluser]
Hi,
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.
Code:
<?php
// controller
class Test extends Controller {
function Test()
{
parent::Controller();
$this->load->scaffolding('cld');
}
function index()
{
$this->load->model('Test_model');
$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);
$this->load->view('includes/footer');
}
}
?>
<?php
// models
class Test_model extends Model {
var $title = '';
var $message = '';
var $date = '';
function Test_model()
{
// Call the Model constructor
parent::Model();
}
function get_cld()
{
$query = $this->db->get('cld');
return $query->result();
}
}
?>
//view
<h1><?php echo $title ?></h1>
<p><?php echo $message ?></p>
<?php foreach($query->related as $row): ?>
<h3><?=$row->title?></h3>
<p><?=$row->message?></p>
<p>Datum: <?=$row->date?></p>
<?php endforeach;?>
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