What is the correct way to call an object from within a class function?
This errors with: ErrorException [ Error ]: Using $this when not in object context:
<?php
class Model_Users extends Model
{
public static function _init()
{
$mongodb = \Mongo_Db::instance('content');
}
public static function get_user($name)
{
$user = $this->mongodb->get('users', array( 'name' => $name ));
return $user;
}
}
Don't use "self::", use "static::".
There is a small but significant difference between the two, which will become appearant when you start extending classes.