[eluser]dwlamb[/eluser]
Hello,
I'm new to CI and trying to get the basics down after looking at some tutorials. For now,
I'm doing things by rote.
I have the following in a controller.
Code:
class Main extends CI_Controller {
public function index()
{
// Standard SQL Query
$sql = "SELECT * FROM main";
$data['query_sql'] = $this->db->query($sql);
$this->load->view('main', $data);
}
}
Then I have the following in a view.
Code:
<?php print_r($query_sql->result_array()); ?>
When I run the script I get an error. This is the abbreviated form (in blue just to make it distinct here):
Undefined property: Main::$db
Call to a member function query() on a non-object
I checked database.php and the information entered for the database is correct.
I'm at a loss to determine what's wrong for I am doing something simple that I was able to do in a tutorial and I'm certain I followed the steps.