MongoDB library for CodeIgniter 3
Run MongoDB queries from CodeIgniter 3 in the same chained, active-record style you already use for SQL.
- Language
- PHP 7+
- Framework
- CodeIgniter 3
- Requires
- mongodb 1.5.x extension
- Licence
- MIT
Overview
CIMongo lets you query MongoDB from CodeIgniter with chained methods such as where(), order_by() and limit(). It supports write concern and journal options, read preference, the aggregation framework and query profiling.
Compatibility
- PHP 7 or higher and CodeIgniter 3.
- The PECL
mongodb1.5.x extension. - Copied into your application, not published on Packagist, so there is no
composer require. - A branch named
unitestingholds the code used for unit tests.
Installation
- Download the repository. It contains
configandlibrariesfolders. - Copy both into your CodeIgniter
applicationfolder. - Set your connection details in
application/config/mongo_db.php. - Autoload the library in
application/config/autoload.php:$autoload['libraries'] = array('mongo_db');
Usage
$users = $this->mongo_db
->where(array('age' => 31))
->order_by(array('name' => 'asc'))
->limit(10)
->get('users');
The full method list, including multiple connections, is in the original CIMongo documentation. To see the queries your app runs, add CIProfiler.