For PHP7+, Codeigniter3+ and mongodb-1.5-x php extension support, use the latest library available at https://github.com/intekhabrizvi/codeigniter-mongodb-library
We tried to make transition as easy as possible by keeping all functions name as is. In most cases new library would be a drop-in replacement for this library, if not please open a bug request in new library.
This library help you to use perform MongoDB based queries just like active record in CodeIgniter.
This library support
- Write Concern and Journal
- Read Preference
- Aggregation Framework
- Query Profiling
Wiki and how-to can be found here http://intekhabrizvi.github.io/mongodb-library-for-codeigniter.html
For Code Unitesting use branch named unitesting
insertInsert a new document into a collectionbatch_insertInsert multiple new documents into a collection
selectGet select fields from returned documentswhereORget_whereWhere section of the querywhere_inWhere something is in an array of somethingwhere_in_allWhere something is in all of an array of * somethingwhere_not_inWhere something is not in array of somethingwhere_orWhere something is based on orwhere_gtWhere something is greater than somethingwhere_gteWhere something is greater than or equal to somethingwhere_ltWhere something is less than somethingwhere_lteWhere something is less than or equal to somethingwhere_betweenWhere something is in between to somethingwhere_between_neWhere something is in between and but not equal to somethingwhere_neWhere something is not equal to somethinglikeWhere something is search by like queryorder_byOrder the resultslimitORoffsetLimit the number of returned resultscountDocument Count based on where querydistinctRetrieve a list of distinct values for the given key across a single collectionfind_oneRetrieve single document from collection
setSets a field to a valueunset_fieldUnsets a fieldaddtosetAdds a value to an array if doesn't existpushPushes a value into an array fieldpopPops a value from an array fieldpullRemoves an array by the value of a fieldrename_fieldRename a fieldincIncrements the value of a fieldmulMultiple the value of a fieldmaxUpdates the value of the field to a specified value if the specified value is greater than the current value of the fieldminUpdates the value of the field to a specified value if the specified value is less than the current value of the field.updateUpdate a single document in a collectionupdate_allUpdate all documents in a collection
deleteDelete a single document in a collectiondelete_allDelete all documents in a collection
aggregatePerform aggregation query on document
output_benchmarkreturn complete explain data for all the find based query performed
add_indexCreate a new index on collectionremove_indexRemove index from collectionlist_indexesShow all index created on collections
switch_dbSwitch to a different databasedrop_dbDrops a databasedrop_collectionDrops a collectioncommandPerform MongoDB command
dateCreate or convert date to MongoDB based Date
Creative Commons Attribution 3.0 License. Codes are provided AS IS basis, i am not responsible for anything.