I am new to codeigniter, and I have developed a code to carry out queries on the database. I load the database using$this->load->database();
and perform a query, but when I run the code, the browser gives me the following error message:
A PHP Error was encountered Severity: Notice Message: Undefined property: Tutorial::$load.
Fatal error: Call to a member function database() on a non-object
This is the code I am using:
class Tutorial extends CI_Controller {
public function tutorial() {
$this->load->database();
$query = $this->db->query('SELECT user,pass,email FROM tablex');
foreach ($query->result() as $row) {
echo $row->title;
echo $row->name;
}
I am sure the $db
variables in my database configuration file are properly set and I have even tried autoloading the database for all pages in the autoload.php config file; still having the same problem. Any ideas how to go about this?