[eluser]cerberus478[/eluser]
Hi
I'm using codeigniter 2.1.2 and I'm busy doing a tutorial called codeigniter from scratch but I get an error saying
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Site::$db
Filename: core/Model.php
Line Number: 51
and
Quote:Fatal error: Call to a member function get() on a non-object in C:\wamp\www\ci\application\models\site_model.php on line 7
I have done everything like the tutorial said
here is my controller
Code:
<?php
class Site extends CI_Controller{
function index(){
$this->load->model('site_model');
$data['records'] = $this->site_model->getAll();
$this->load->view('home', $data);
}
}
?>
This is my model
Code:
<?php
class Site_model extends CI_Model
{
function getAll()
{
$q = $this->db->get('test');
if($q->num_rows > 0)
{
foreach($q->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
}
?>
This is my view
Code:
<html>
<head>
<title>
</title>
</head>
<body>
<div id="container">
<p>My view has been loaded</p>
<pre>
<?php print_r($records); ?>
</pre>
</div>
</body>
</html>