Giter Club home page Giter Club logo

ormci's Introduction

ORMCI

Simple library database untuk penggunaan Codeigniter Dengan menggunakan library ini, anda bisa mudah proses lebih dari satu database pada sebuah model dan library lainnya.

Cara Install

  • Tambahkan Library M_db.php ke folder application/libraries
  • Buatlah model untuk memproseskan database

Konfigurasi Database

$db['default'] = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => '',
	'database' => 'default_db',
	'dbdriver' => 'mysqli',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => (ENVIRONMENT !== 'production'),
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);

$db['internal'] = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => '',
	'database' => 'other_db',
	'dbdriver' => 'mysqli',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => (ENVIRONMENT !== 'production'),
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);

Contoh Pemakaian

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Sample extends CI_Model
{
	private $default;
	private $other;
	function __construct()
	{
		$this->load->library('m_db');
		$this->default=new M_db(); // For Default Group Database
		$this->other=new M_db('otherdb'); //For Other Group Database
	}
	
	function get_default($where=array(),$order="",$group_by='')
	{
		$d=$this->default->get_data('default_table',$where,$order,$group_by);
		return $d;
	}
	
	function get_other($where=array(),$order="",$group_by='')
	{
		$d=$this->other->get_data('other_table',$where,$order,$group_by);
		return $d;
	}
	
	function find_id($fieldDefaultID,$output='')
	{
		$s=array('ID'=>$fieldDefaultID);
		$item=$this->default->get_row('default_table',$s,$output);
		return $item;
	}
	
	function count_table()
	{
		$count=$this->default->count_data('default_table');
		return $count;
	}
	
	function insert_data($field1,$field2)
	{
		$d=array(
			'field1'=>$field1,
			'field2'=>$field2,
		);
		if($this->default->add_row('default_table',$d)==TRUE)
		{
			return true;
		}else{
			return false;
		}
	}
	
	function edit_data($primaryKey,$field1,$field2)
	{
		$s=array(
			'ID'=>$primaryKey
		);
		$d=array(
			'field1'=>$field1,
			'field2'=>$field2,
		);
		if($this->default->edit_row('default_table',$d,$s)==TRUE)
		{
			return true;
		}else{
			return false;
		}
	}
	
	function delete_row($primaryKey)
	{
		$s=array(
			'ID'=>$primaryKey
		);
		if($this->default->delete_row('default_table',$s)==TRUE)
		{
			return true;
		}else{
			return false;
		}
	}
	
}

Contoh Function Lain (Soon)

ormci's People

Contributors

herurahmat avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.