NotORM can be integrated with codeigniter in 3 easy steps.
1. unzip the contents of NotORM in application/libraries folder. You should have NotORM.php and NotORM directory in the libraries folder. The tests folder can be removed.
2. create a new file Orm.php in the application/libraries folder as listed below:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once "NotORM.php" ;
class Orm extends NotORM{
function __construct(NotORM_Structure $structure = null, NotORM_Cache $cache = null){
$CI =& get_instance();
$CI->load->database(); //required to get the db parameters
//Please set $active_record = FALSE & $db['default']['autoinit'] = FALSE;
//in case you don't intend to use them, for low resource usage and better performance
$connection = new PDO("{$CI->db->dbdriver}:dbname={$CI->db->database};host={$CI->db->hostname}",
$CI->db->username,
$CI->db->password);
parent::__construct($connection, $structure, $cache);
}
}
3. Its done. You can now use NotORM in your controllers by simply loading the library orm. and accessing the new NotORM object as $this->orm. example given below.
class Welcome extends CI_Controller{
function index(){
$this->load->library(orm);
//NotORM object is now available as $this->orm
foreach ($this->orm->users() as $user){
echo $user['name'];
}
}
}
------------------------------------
Enjoy. CI with NotORM - CI