You are here

CodeIgniter - Fired Up on NuoDB

CodeIgniter is a powerful PHP framework with a very small footprint.  It is built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.  I will show you how you can use NuoDB to power the CodeIgniter tutorial “News” application. The CodeIgniter website is:

In this blog article, I am using clean install of 64-bit Linux Mint 15. (note: the commands and paths below may be different on other Linux distributions).


Install and Configure NuoDB

We will start by downloading NuoDB then install NuoDB and run the quickstart. To use NuoDB with PHP, you will need to install and configure the NuoDB PHP PDO Driver. The source code is available on GitHub, but you probably won’t need to build it yourself because your NuoDB installation already contains pre-built drivers for PHP 5.3 NTS and PHP 5.4 NTS.


PHP Configuration

The Linux Mint 15 distro uses PHP 5.4.9 NTS. You can see this with the following command:

$ php -i | grep "PHP Version"
PHP Version => 5.4.9-4ubuntu2.1

Next, we can find the location of the PHP extension_dir:

$ php -i | grep extension_dir
extension_dir => /usr/lib/php5/20100525 => /usr/lib/php5/20100525

Install and Configure NuoDB PHP PDO Driver

Having obtained the PHP version and extension_dir, we can copy the correct NuoDB PHP PDO Driver to that extension_dir with the following command:

$ sudo cp /opt/nuodb/drivers/php_pdo/php-5.4.NTS/ /usr/lib/php5/20100525

Next, we need to modify the PHP Configuration to dynamically load the NuoDB PHP PDO Driver. This is done by adding “” to your PHP initialization files. On Mint 15, PHP is configured to scan specific directories for PHP .ini files. The command line version of PHP scans the /etc/php5/cli/conf.d directory. When PHP is executed from Apache2, PHP is configured to scan /etc/php5/apache2/conf.d directory. To add NuoDB to those PHP configurations, we can use that extension statement in a file named 15-nuodb.ini and copy that file to those config directories:

$ echo ""> /tmp/15-nuodb.ini
$ sudo cp /tmp/15-nuodb.ini /etc/php5/cli/conf.d/
$ sudo cp /tmp/15-nuodb.ini /etc/php5/apache2/conf.d/
$ sudo /etc/init.d/apache2 restart


Verify Proper Loading of NuoDB PHP PDO Driver

We can verify the proper configuration and loading of the NuoDB PHP PDO Driver by calling the phpinfo() function from a .php file that we can copy to the default Apache2 website. Example:

$ echo ""> /tmp/phpinfo.php
$ sudo cp /tmp/phpinfo.php /var/www/

Then use the web browser with the URL:



Download CodeIgniter

You can download CodeIgniter from the website and extract it into /var/www:

$ wget -O ${HOME}/
$ cd /var/www/
$ sudo unzip ${HOME}/
$ cd CodeIgniter_2.1.3


CodeIgniter News Tutorial

CodeIgniter has a simple tutorial application which is called “news”.   The instructions for the CodeIgniter News tutorial is on the CodeIgniter website:

You should follow the instructions on that website, or if you are lazy, you can download the complete tutorial from the NuoDB website at:


Using NuoDB

To use NuoDB with CodeIgniter, modify the application/config/database.php to use:

$db['default']['hostname'] = 'nuodb:database=test@localhost;schema=CodeIgniter';
$db['default']['username'] = 'dba';
$db['default']['password'] = 'goalie';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'pdo';

Then start up the NuoDB processes and create a “news” database using the nuosql command prompt:

$ /opt/nuodb/bin/nuosql test@localhost --user dba --password goalie
SQL> create schema CodeIgniter;
SQL> use CodeIgniter;
"id" int NOT NULL generated by default as identity,
"title" varchar(128) NOT NULL,
"slug" varchar(128) NOT NULL,
"text" text NOT NULL,
SQL> insert into news ("title", "slug", "text") values ('red sox win', 'tgates', 'The red sox win the world series!');
SQL> insert into news ("title", "slug", "text") values ('NuoDB 1.1.1', 'tgates', 'NuoDB version 1.1.1 is now available for download!');
SQL> exit;


Running the News example

Open your web browser to the url:


Add new comment