I'm trying to use variables in a model, but not having much luck. Here is basically what I have:
class Model_Currency extends \Model_Crud
{
private static $country = 'GBP';
public static function get_currency_code(){
$code = DB::query('SELECT currencyCode FROM currency_code WHERE countryCode = "' . $self::country . '" LIMIT 1')->execute();
$code = $code->as_array();
return $code[0]['currencyCode'];
}
}
But I get an error:Undefined class constant 'country' referring to the get_currency_code function.
I tried non-statically too with non-static variable and refer to it in the function as $this->country, but get error:Using $this when not in object context
I also tried sticking the variable in an init function - like you would a constructor, but that didn't work either!