[eluser]Unknown[/eluser]
Hello
Can someone tell me how to run a Model example, I cant get it working.
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Blog::$load
Filename: controllers/blog.php
Line Number: 8
Fatal error: Call to a member function database() on a non-object
Code:
<?php
class Blog extends Controller {
function blog()
{
$this->load->database();
$this->load->model('blog', '', TRUE);
$data['query'] = $this->Blog->get_last_ten_entries();
$this->load->view('blog', $data);
}
}
?>
Code:
<?php
class Blog extends Model {
var $title = '';
var $content = '';
var $date = '';
function Blog()
{
// Call the Model constructor
parent::Model();
}
function get_last_ten_entries()
{
$query = $this->db->get('entries', 10);
return $query->result();
}
?>
Code:
<html>
<body>
<?php foreach($data as $item):?>
<?php echo $item;?>
<?php endforeach;?>
</body>
</html>