How to use Couchdb NoSQL database on CodeIgniter

Leave a comment

Here I will explain how to use CouchDB NoSQL database on CodeIgniter using PHP On Couch open source library (Data Access Library to access a CouchDB server with PHP).

PHP On Couch tries to provide an easy way to work with your CouchDB documents with PHP.

Here I assume you know PHP and CodeIgniter. If don’t go through http://ellislab.com/codeigniter Its running on your system.

Here is How to use Couchdb NoSQL database on CodeIgniter?

First Download PHP On Couch from here:


Setup instructions:


1.) copy the PHP on Couch classes

copy all from /PHP-on-Couch-master/lib/

to /CodeIgniter_2.1.4/application/libraries/

2.) copy the PHP on Couch CI classes

copy from /PHP-on-Couch-master/frameworks/ci/libraries/

to /CodeIgniter_2.1.4/application/libraries/

3.) copy the config/couchdb.php file inside the config folder of your application/libraries/

copy from /PHP-on-Couch-master/frameworks/ci/config

to /CodeIgniter_2.1.4/application/config/

4.) edit the config/couchdb.php file to set the two configuration options couch_dsn and couch_database :

$config[‘couch_dsn’] = “http://localhost:5984/“;

$config[‘couch_database’] = “my_wonderful_db”;

5.) if you want the couchdb object to be autoloaded, edit the config/autoload.php file of your CodeIgniter application and add “couchdb” to the list of libraries to autoload

$autoload[‘libraries’] = array(‘couchdb’);

6.) Thats it!













How to set InnoDB as a default storage engine for MySQL tables


I use InnoDB storage engine in my projects because of its support for transactions and referral integrity rules. However, MySQL still creates new tables as MyISAM by default. It was so annoying for me to always define storage engine when creating new tables and double check that I didn’t forget it until I found how I can set InnoDB as default.

The solution is very easy:

  1. Open your MySQL configuration file: my.cnf or my.ini depending on your operation system.
  2. Locate [mysqld] section which usually goes at the top of file.
  3. Add this setting to the section:

    default-storage-engine = InnoDB

  4. Restart MySQL server.
  5. Enjoy your new new tables created as InnoDB w/o any additional worry.

The setting is applied to CREATE TABLE queries as well as tables created with phpMyAdmin, navicat and possibly any other MySQL client.

If you can’t change MySQL configuration file you still can change default storage engine used during a session by setting storage_engine system variable:

SET storage_engine=InnoDB;

More Info








MySQL Web / Desktop Management Tools

Leave a comment

1.) phpMyAdmin
phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement.
2.) Adminer
Adminer (formerly phpMinAdmin) is a full-featured MySQL management tool written in PHP. Conversely to phpMyAdmin, it consist of a single file ready to deploy to the target server.
3.) MySQL Workbench

MySQL Workbench is a unified visual tool for database architects, developers, and DBAs. MySQL Workbench provides data modeling, SQL development, and comprehensive administration tools for server configuration, user administration, and much more. MySQL Workbench is available on Windows, Linux and Mac OS.


4.) HeidiSQL – a free MySQL front-end


HeidiSQL is an easy-to-use interface and a “working-horse” for web-developers using the popular MySQL-Database. It allows you to manage and browse your databases and tables from an intuitive Windows® interface.

5.) Navicat well-designed (GUI), Navicat for MySQL

Navicat for MySQL is a powerful Database administration and development tool for MySQL. It works with any MySQL Database Server from version 3.21 or above, and supports most of the latest MySQL features including Trigger, Stored Procedure, Function, Event, View, and Manage User, etc.


6.) EMS SQL Manager for MySQL

EMS SQL Manager for MySQL is a high performance tool for MySQL database administration and development. It works with any MySQL versions from 3.23 to the newest one and supports all of the latest features including MySQL triggers, views, stored procedures and functions, InnoDB foreign keys, Unicode data and so on. SQL Manager for MySQL allows you to create/edit all MySQL database objects, design MySQL databases visually, run SQL scripts, import and export MySQL database data, manage MySQL users and their privileges and has many other useful features for efficient MySQL administration. SQL Manager for MySQL has a state-of-the-art graphical user interface with well-described wizard system, so clear in use that even a newbie will not be confused


7.) SIDU 3.2 DB Web GUI


8.) SQLyog MySQL GUI

SQLyog MySQL GUI is the most powerful MySQL manager and admin tool, combining the features of MySQL Query Browser, Administrator, phpMyAdmin and other MySQL Front Ends and MySQL GUI tools in a single intuitive interface.


9.) MySQL-Front



More information here:



SQL for Beginners

Leave a comment

What You Need

SQL (Structured Query Language) is a language designed for interacting with relational database management systems (RDBMS), like MySQL, Oracle, Sqlite etc… To perform the SQL queries in this article, I suggest that you have MySQL installed. I also recommend phpMyAdmin as a visual interface to MySQL.

The following applications make it very easy to install both MySQL and phpMyAdmin on your local machine:

We are going to use command line for queries. WAMP already comes with a MySQL Console. For MAMP, you may want to read this article.

If you would like to follow the examples in this article on your own development server, do the following:

  1. Open MySQL Console and login.
  2. If you haven’t already, create a database named “my_first_db” with a CREATE query.
  3. Switch to the database with the USE statement.

When creating a database, common sense dictates that we use separate tables for different types of entities. Some examples are: customers, orders, items, messages etc… But we also need to have relationships between these tables. For instance, customers make orders, and orders contain items. These relationships need to be represented in the database. Also, when fetching data with SQL, we need to use certain types of JOIN queries to get what we need.

There are several types of database relationships. Today we are going to cover the following:

  • One to One Relationships
  • One to Many and Many to One Relationships
  • Many to Many Relationships
  • Self Referencing Relationships

When selecting data from multiple tables with relationships, we will be using the JOIN query. There are several types of JOIN’s, and we are going to learn about the the following:

  • Cross Joins
  • Natural Joins
  • Inner Joins
  • Left (Outer) Joins
  • Right (Outer) Joins

We will also learn about the ON clause and the USING clause.

Catch Up All Here

Read the rest of entries here »


%d bloggers like this: