-
Notifications
You must be signed in to change notification settings - Fork 446
Integrating AlexBilbies MongoDB Library into Fat Free
Joseffb edited this page Apr 10, 2013
·
2 revisions
- Get library: https://github.com/alexbilbie/codeigniter-mongodb-library/tree/v2, place into the library folder, or custom library folder. (auto load the custom folder).
- Create new config file called mongo.cfg and place in your config folder.
Add following to your config:[globals]
MongoDB[mongo_hostbase] = localhost:27017
MongoDB[mongo_database] = ModularMeter
MongoDB[mongo_username] =
MongoDB[mongo_password] =
MongoDB[mongo_persist] = TRUE
MongoDB[mongo_persist_key] = ci_persist
MongoDB[mongo_replica_set] = FALSE
MongoDB[mongo_query_safety] = safe
MongoDB[mongo_suppress_connect_error] = TRUE
MongoDB[mongo_host_db_flag] = FALSE
- Load Mongo library if you havent auto loaded it.
- add to your index (or anywhere you use it):
$f3->config('config/mongo.cfg'); //load your config items.
$MongoConfig = $f3->get('MongoDB');
$f3->set('MongoObj',new Mongo_db($MongoConfig));
- Modify the library:
- bottom of _construct replace $this->load(); with $this->load(func_get_args());
- Line 1834 replace:
if($this->_config_data['mongo_suppress_connect_error']) with if($this->_config_data[0]['mongo_suppress_connect_error']) - Line 1854 through 1861 replace:
$this->_host = trim($this->_config_data['mongo_hostbase']);
$this->_user = trim($this->_config_data['mongo_username']);
$this->_pass = trim($this->_config_data['mongo_password']);
$this->_dbname = trim($this->_config_data['mongo_database']);
$this->_persist = $this->_config_data['mongo_persist'];
$this->_persist_key = trim($this->_config_data['mongo_persist_key']);
$this->_replica_set = $this->_config_data['mongo_replica_set'];
$this->_query_safety = trim($this->_config_data['mongo_query_safety']);
$dbhostflag = (bool) $this->_config_data['mongo_host_db_flag'];
with:
$this->_host = trim($this->_config_data[0]['mongo_hostbase']);
$this->_user = trim($this->_config_data[0]['mongo_username']);
$this->_pass = trim($this->_config_data[0]['mongo_password']);
$this->_dbname = trim($this->_config_data[0]['mongo_database']);
$this->_persist = $this->_config_data[0]['mongo_persist'];
$this->_persist_key = trim($this->_config_data[0]['mongo_persist_key']);
$this->_replica_set = $this->_config_data[0]['mongo_replica_set'];
$this->_query_safety = trim($this->_config_data[0]['mongo_query_safety']);
$dbhostflag = (bool) $this->_config_data[0]['mongo_host_db_flag'];
Done