Code Monkey home page Code Monkey logo

activerecordex's Introduction

README

ActiveRecordEx
--------------
This is an enhanced Active Record for Code Igniter allowing grouping of where statements. 

For example consider this query:
SELECT * FROM `user` WHERE `user`.`status`=1 AND (`user`.`id_department` = 1 OR `user`.`id_department` = 2)

Using ActiveRecordEx you can do the following:
$this->db->select("users.*")->from('users')->where('user.status',1)->group_start()->where('user.id_department',1)->or_where('user.id_department',2)->group_end();

ActiveRecordEx adds the following statements to the db driver:

$this->db->group_start()	: Opens a parenthesis 
$this->db->group_end()		: Closes a parenthesis
$this->db->and_()			: Joins two clauses using an AND statement		
$this->db->or_()			: Joins two clauses using an OR statement		

Some examples:
--------------
Using and_()
------------
$this->db->from('appointment')->where('user_id',1)->and_()->group_start()->where('status',1)->or_where('status',2)->group_end()->get();
SELECT * FROM `appointment` WHERE `user_id` = 1 AND (`status`=1 OR `status`=2)

Using or_()
-----------
$this->db->from('appointment')->where('user_id',1)->and_()->group_start()->where('status',1)->or_where('status',2)->group_end()->get();


I have successfully tested for the following cases:
or_where() 
where_in()
or_where_in()
where_not_in()
or_where_not_in()
like()
or_like()
not_like()
or_not_like()


Installation:
-------------

Code Igniter does not allow you to extend the active record class using a prefix, yet we can achieve it fairly simply as explained in:
http://www.webrevised.com/extending-code-igniter-active-record-class/

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.