So i'm looking at http://ellislab.com/expressionengine/user-guide/development/usage/database.html
I've used
$query = $this->EE->db->query("SELECT channel_name FROM exp_channels");
many times, but never within a class. and using $this-> causes issues. I'm no expert but how do i overcome this?
class Name
{
public $variable;
public function Something()
{
if($this->variable == "whatever")
{
//Run query to pull data based on $variable
// This causes errors. I assume because $this is now something else.
$this->EE->db->query("SELECT * FROM tablename WHERE...");
}
}
}
Message: Undefined property: Module::$EE
Message: Trying to get property of non-object
Fatal error: Call to a member function query() on a non-object