class lazyLoad_mongo {
private $loaded = false;
private $mongo;
public function init() {
$this->mongo = new Mongo(MONGO_SERVER, array ("connect" => false));
$this->loaded = true;
}
public function __call($name, array $arguments) {
if (!$this->loaded) {
$this->init();
}
return call_user_func_array(array($this->mongo, $name), $arguments);
}
public function __callStatic($name, array $arguments) {
$this->__call($name, $arguments);
}
public function __get($name) {
if (!$this->loaded) {
$this->init();
}
return $this->mongo->$name;
}
public function __set($name, $value) {
if (!$this->loaded) {
$this->init();
}
return $this->mongo->$name = $value;
}
public function __isset($name) {
if (!$this->loaded) {
$this->init();
}
return isset($this->mongo->$name);
}
public function __unset($name) {
if (!$this->loaded) {
$this->init();
}
return unset($this->mongo->$name);
}
}