Home > Database, Mongo, PHP, Programming > CodeIgniter & TokuMX

CodeIgniter & TokuMX

CodeIgniter is a lightweight PHP framework that can help you to develop Web Application. TokuMX is a drop-in replacement for MongoDB, that support transaction.

You can download codeigniter from here, and TokuMX from here . For more information about how to install TokuMX, you can read TokuMX documentation from GitHub here.

To Make Web Application can connect to Mongo Instance, you need to install PHP extension for mongo. To Install in Centos or Redhat environment, run command :

pecl install mongo

and add to /etc/php.ini


Restart Web Service

service httpd restart

Download codeigniter-mongo-library from here .

Here’s simple code example how to use codeigniter-mongo-library to perform CRUD operation.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller
  // Insert Operation
  public function mongo_insert_test()      
     for($i=0;$i<25;$i++) {
            ->insert("testData", array("x" => $i, "y" => 25-$i ));

  // Select Operation 
  public function mongo_select_test()
     $mongo_data = $this->cimongo->get("testData");
     foreach($mongo_data->result_array() as $row) {
        echo sprintf('x:%d,y:%d <br>',$row['x'],$row['y']);
  // Update Operation
  public function mongo_update_test()
     $result = $this->cimongo->where(array("x" => 24 ))
                    ->set(array("x" => 25 ))->update("testData");
     echo $result

  // Delete Operation
  public function mongo_delete_test()
     $result = $this->cimongo->where(array("x" => 25 ))
     echo $result;




Categories: Database, Mongo, PHP, Programming
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: