Welcome Guest, Not a member yet? Register   Sign In
Undefined Variable when loading a database?
#2

[eluser]Armchair Samurai[/eluser]
You haven't defined $callan_db for the entire class, just the constructor. You'll need to do this:

Code:
class Report_model extends Model {

    var $callan_db;

    function Report_model()
    {
        parent::Model();
        $this->callan_db = $this->load->database('callan', TRUE);
    }
    
    function test()
    {

        $query = $this->callan_db->query("SELECT * FROM golfpro_barsales");
        
        if ($query->num_rows() > 0)
        {
           $row = $query->row_array();
        
           echo $row['year'];
        }

    }

}


Messages In This Thread
Undefined Variable when loading a database? - by El Forum - 01-02-2009, 09:38 AM
Undefined Variable when loading a database? - by El Forum - 01-02-2009, 10:01 AM
Undefined Variable when loading a database? - by El Forum - 01-02-2009, 10:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB