public function __construct($collectionName, $dateTimeField = null) { $this->collectionName = $collectionName; $this->dateTimeField = $dateTimeField != null ? $dateTimeField : null; $this->dbh = MongoDBFactory::getDBHandler(); $this->colh = $this->dbh->{$collectionName}; }
/** * @return Database Handler */ public static function getDBHandler() { if ( !isset(self::$dbh) ) { global $mongodb_i; $dbname = $mongodb_i['dbname']; $ret = null; try { $replicaSet = trim($mongodb_i['replicaSet']); if (strlen($replicaSet) > 0) { $ret = new Mongo('mongodb://'.$mongodb_i['host'], array("replicaSet" => $replicaSet) ); } else { $ret = new Mongo('mongodb://'.$mongodb_i['host'] ); } $ret = $ret->$dbname; // select a database } catch(Exception $e) { die('MongoDBFactory: '.$e->getMessage()); } self::$dbh = $ret; return self::$dbh; } return self::$dbh; }