function db() { $_this =& Mongo::getInstance(); if ($_this->mongo == null or $_this->db == null) { return null; } return $_this->mongo->{$_this->db}; }
function can_connect() { $this->__db = Mongo::getInstance(); try { return $this->__db->connected(); } catch (\MongoConnectionException $e) { return false; } }
<?php namespace app; use lib\Configure; Configure::getInstance(); Configure::write('version', '0.1.3'); Configure::write('database', array('connect' => 'mongodb://localhost:27017', 'database' => 'timesheet')); Configure::write('template_engine', 'dwoo'); use lib\db\Mongo; Mongo::getInstance(); Mongo::init(Configure::read('database'));