CodeIgniter Forums

Full Version: database.php config not being loaded
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]infinivert[/eluser]
I seem to be having the same issue, but I'm not auto-loading. I am using HMVC, but all my other models work just fine. Here's my complete model:
Code:
<?php

class Player_model extends Model {

    function Player_model()
    {
        parent::Model();

        $this->load->database();
    }
    
    function getMediaByType($media_type,$limit=100)
    {
        //Get everything from tblMedia where media_type = $media_type
        $this->db->order_by("pub_date", "desc");
        $query = $this->db->get_where('tblMedia', array('media_type' => $media_type), $limit);
        return ($query->result());
    }
}

?>

And here's the error I'm getting:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Player_model::$db

Filename: models/player_model.php

Line Number: 16

Any ideas?

Thanks!

--Josh

El Forum

[eluser]InsiteFX[/eluser]
Your missing the $offset in the get_where

InsiteFX

El Forum

[eluser]infinivert[/eluser]
I use get_where without declaring an offset all the time with no problems. However, for the sake of testing, I tried adding in an offset, and I get the same results.

What DID seem to make a difference, bizarre as it sounds, was calling $this->load->database() from the Controller rather than the model. So weird... I have no idea why that worked.
Pages: 1 2