Hello I just watched the first/Day1 screencast on Nettuts "CodeIgniter from scracth" And I'm already running into an error I don't understand. Here's a screenshot http://i39.tinypic.com/14mtc0n.jpg
The code in my models\site_model.php is the same as the screencast
   models\site_model.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;
    }
}
And the controller controllers\site.php
   class Site extends CI_Controller {
function index(){
    $this-> load-> model('site_model'); 
    $data['records'] = $this-> site_model-> getAll();
    $this-> load-> view('home', $data);
}   
 }
And here's my db info incase
 $db['default']['hostname'] = 'localhost';
 $db['default']['username'] = 'root';
 $db['default']['password'] = '';
 $db['default']['database'] = 'ci_series';
(rest is default below)
Thank you
You need to load the database first. Codeiginiter won't load it by default for you.
You can either add it to /config/autoload.php like so
$autoload['libraries'] = array('database');
Or you can load it on demand whenever you want by calling
$this->load->database();
More details here
http://codeigniter.com/user_guide/database/connecting.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With