I've never developed before and I'm a bit puzzled, what is wrong with my syntax here?
private static $instance; //holder of Mongo_Wrapper
public $connected = true;
private $mongo = null; // The mongo connection affiliation
private $database = null; // The database we are working on
with this function:
public function mongo_connect($db_name) {
if (! self::connected) {
$this->mongo = new Mongo;
//TODO: error handle this whole sharade: throw new Kohana_Database_Exception('Cant connect', NULL, 503);
$this->connected = true;
}
$this->database = $this->mongo->$db_name; //set the database we are working on
return $connected;
}
I'm sorry, wmd-editor is giving me hell posting the code.
Thank you!
edit: $connected isn't static, the problem is it isn't working either with static or with $this. Also, this is a singleton class, I don't know if this is important or not.
edit: this is the rest of the code, here self and this worked properly:
public static function singleton($db_name) {
if (!isset(self::$instance)) {
$c = __CLASS__;
$this->$instance = new $c;
}
self::mongo_connect($db_name);
return self::$instance;
}
enter code here
class Foo { }, right?