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
insert
Insert a new document into a collectionbatch_insert
Insert multiple new documents into a collection
select
Get select fields from returned documentswhere
ORget_where
Where section of the querywhere_in
Where something is in an array of somethingwhere_in_all
Where something is in all of an array of * somethingwhere_not_in
Where something is not in array of somethingwhere_or
Where something is based on orwhere_gt
Where something is greater than somethingwhere_gte
Where something is greater than or equal to somethingwhere_lt
Where something is less than somethingwhere_lte
Where something is less than or equal to somethingwhere_between
Where something is in between to somethingwhere_between_ne
Where something is in between and but not equal to somethingwhere_ne
Where something is not equal to somethinglike
Where something is search by like queryorder_by
Order the resultslimit
ORoffset
Limit the number of returned resultscount
Document Count based on where querydistinct
Retrieve a list of distinct values for the given key across a single collectionfind_one
Retrieve single document from collection
set
Sets a field to a valueunset_field
Unsets a fieldaddtoset
Adds a value to an array if doesn't existpush
Pushes a value into an array fieldpop
Pops a value from an array fieldpull
Removes an array by the value of a fieldrename_field
Rename a fieldinc
Increments the value of a fieldmul
Multiple the value of a fieldmax
Updates the value of the field to a specified value if the specified value is greater than the current value of the fieldmin
Updates the value of the field to a specified value if the specified value is less than the current value of the field.update
Update a single document in a collectionupdate_all
Update all documents in a collection
delete
Delete a single document in a collectiondelete_all
Delete all documents in a collection
aggregate
Perform aggregation query on document
output_benchmark
return complete explain data for all the find based query performed
add_index
Create a new index on collectionremove_index
Remove index from collectionlist_indexes
Show all index created on collections
switch_db
Switch to a different databasedrop_db
Drops a databasedrop_collection
Drops a collectioncommand
Perform MongoDB command
date
Create 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.