This is a repositories pattern for Codeigniter's Model. All the reuseable function are availables inside both base and extended model classes which can call directly from extended model for particular database's table without re-writing the same logic for querying.
- PHP 5.6 and above ( no backward compatibility as the code were used
...args
) - Codeigniter — For best outcome, used the latest and stable version
Installion are quite easy as following :
- Download latest release v1.2.2 from
release
tab or click here. - After extracting the archive, it should have 2 folders inside
applications
which aremodels
andtraits
- Copy all the files inside
models
folder and paste it in your project'smodels
folder. - Create
traits
folder insideapplication
folder from your project directory. - Copy the files inside
traits
folder from downloaded directory and pasted it in your project'straits
folder. - Finish!
Must be noted that, reuseable code already defined and created inside main model file which is extended from CI_Model
directly. In order to make its code usable in newly created model's file, we must extend and take advantages of it. The rules is simple :
- When creating new model's file, just extend the base model. Let's create
User_model.php
file insidemodels
folder :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// requiring once the base class
require_once APPPATH.'/models/Model_app.php';
// extend the base class
class User_model extends Model_app {
// create protected property, this mainly used for
// table operation. So, be sure to put database table's name
// for each model
protected $table = 'users';
function __construct()
{
// Call the Model constructor
parent::__construct();
}
// at here you can write your own query as usual
// for completed built-in query had made and availables
// for you to use it, see #available_function below
}
- Finish!. Simple enough right?
- insert
- insert_batch
- delete
- clear
- truncate
- get_last_data
- get_all_rows
- get_specified_row
- update
- update_batch
- replace
- max
- min
- avg
- sum
- count
- where
- or_where
- having
- or_having
- where_in
- or_where_in
- where_not_in
- or_where_not_in
- like
- like_before
- like_after
- or_like
- or_like_before
- or_like_after
- not_like
- not_like_before
- not_like_after
- or_not_like
- or_not_like_before
- or_not_like_after
- Will coming more soon...
We'll used extended/child class instead of calling base class directly. In this case is our User_model.php
. This is only an example, you can have your own model that extend the base class.
Insert data into table
Parameters
$arrayData
= array REQUIRED. Key(column's name) value(column's value) paired array$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
If success, will return last inserted ID, ONLY if the inserted table have an Incremented ID or will return TRUE if an Incremented ID wasn't existed, FALSE otherwise. Must be noted that, in PHP TRUE also are equal to 1. If the inserted table didn't have an Incremented ID, but the result is return 1,then it mean TRUE.
// insert into users table without specify table's name
$arrayData = [ 'name' => 'norlihazmey', 'email' => 'norlihazmey89@gmail.com' ];
$result = $this->user_model->insert( $arrayData );
-----------------------or---------------------------------
// insert into users table with table's name
$arrayData = [ 'name' => 'norlihazmey', 'email' => 'norlihazmey89@gmail.com' ];
$table = 'users_contact';
$result = $this->user_model->insert( $arrayData, $table );
Insert data into table batch by batch
Parameters
$arrayData
= array REQUIRED. Collection of Key(column's name) value(column's value) paired array$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
If success will return TRUE, FALSE otherwise
// insert into users table without specify table's name
$arrayData = array(
array(
'name' => 'Norlihazmey',
'email' => 'norlihazmey89@gmail.com'
),
array(
'name' => 'Metallurgical',
'email' => 'norlihazmey89@yahoo.com'
)
);
$result = $this->user_model->insert_batch( $arrayData );
-----------------------or---------------------------------
// insert into users table with table's name
$table = 'users_contact';
$result = $this->user_model->insert_batch( $arrayData, $table );
Delete data from table either single or multiple table
Parameters
$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
Return 1 if success, 2 if no delete occured, 3 if delete operation can't be done.
// Single deleted
$where = array('id' => 1);
$this->user_model->delete( $where )
-----------------------or---------------------------------
// multiple deleted
$where = array('id' => 1);
$table = array('users','users_booking','users_history');
$this->user_model->delete( $where, $table )
Will empty the data inside database's table. Same like @truncate method except this use DELETE keyword
Parameters
$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
If success return TRUE, FALSE otherwise
// empty without table's name
$this->user_model->clear();
-----------------------or---------------------------------
// empty with table's name
$table ='users_contact';
$this->user_model->clear( $table );
Will empty the data inside database's table. Same like @clear method except this use TRUNCATE keyword
Parameters
$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
If success return TRUE, FALSE otherwise
// empty without table's name
$this->user_model->truncate();
-----------------------or---------------------------------
// empty with table's name
$table ='users_contact';
$this->user_model->truncate( $table );
Get the last data from table
Parameters
$fieldToOrder
= string REQUIRED. Which columns to make ordering.$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$fieldToSelect
= string|array OPTIONAL. Columns to select. Select all column if not specified.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. See @get_all_rows implementation.
Return
Single array key-value paired if found, EMPTY otherwise
// get the last data and include all column desc by id
$fieldToOrder = 'id';
$this->user_model->get_last_data( $fieldToOrder );
-----------------------or---------------------------------
// get the last data and select only name, email column desc by id
$table ='users_contact';
$fieldToOrder = 'id';
$fieldToSelect = 'name, email';
$this->user_model->get_last_data( $fieldToOrder, $field, $table );
-----------------------or---------------------------------
// get the last data using condition column desc by id
$fieldToOrder = 'id';
$where = ['email' => 'norlihazmey89@gmail.com' ];
$this->user_model->get_last_data( $fieldToOrder, $where );
Get data more than one rows from database's table. This method accept various sql keyword to perform any database operation. You can either use all where, join, like, family etc that exist on codeigniter's quiry builder.
Parameters
-
$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition .Perform various where condition on single query. Availables where condition can be used are:- where :
array( 'where' => [ 'id !=' => 1, 'email =' => 'emi@emi.com' ] )
- where_in
array( 'where_in' => [ 'id'=> [1, 2], 'email' => ['emi@emi.com'] ] )
- or_where_in
array( 'or_where_in' => [ 'id'=> [1, 2], 'email' => ['emi@emi.com'] ] )
- where_not_in
array( 'where_not_in' => [ 'id'=> [1, 2], 'email' => ['emi@emi.com'] ] )
- or_where_not_in
array( 'or_where_not_in' => [ 'id'=> [1, 2], 'email' => ['emi@emi.com'] ] )
- or_where
array( 'or_where' => [ 'id !=' => 1, 'email =' => 'emi@emi.com' ] )
- having
array( 'having' => [ 'id !=' => 1, 'email =' => 'emi@emi.com' ] )
- or_having
array( 'or_having' => [ 'id !=' => 1, 'email =' => 'emi@emi.com' ] )
- like
array( 'like' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- like_before
array( 'like_before' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- like_after
array( 'like_after' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- or_like
array( 'or_like' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- or_like_before
array( 'or_like_before' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- or_like_after
array( 'or_like_after' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- not_like
array( 'not_like' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- not_like_before
array( 'not_like_before' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- not_like_after
array( 'not_like_after' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- or_not_like
array( 'or_not_like' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- or_not_like_before
array( 'or_not_like_before' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- or_not_like_after
array( 'or_not_like_after' => [ 'name' => 'emi', 'email' => 'emi@emi.com' ] )
- where :
-
$fields
= string|array OPTIONAL. sql string or key-value paired array. -
$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default. -
$join
= array OPTIONAL. key value paired array. Available join can be used are :- left
array('left' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- right
array('right' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- left outer
array('left outer' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- right outer
array('right outer' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- join
array('join' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- outer
array('outer' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- inner
array('inner' => [ 'users_groups' => 'users.id = users_groups.user_id',...more ] )
- left
-
$orderBy
= string|array OPTIONAL. Which columns need to make ordering -
$groupBy
= string|array OPTIOANL. Which columns need grouping -
$limit
= string|array OPTIOANL. Set the limit or offset result set
Return
Array collection. Collection of dataset coming/fetching from database's table with one or more rows are returned
// Example 1 : Using 1st parameter = WHERE and LIKE condition
// Availables where condition can be used is, where, where_in, or_where_in, where_not_in, or_where_not_in,or_where, having, or_having, like, like_before, like_after, or_like, or_like_before, or_like_after, not_like, not_like_before, not_like_after, or_not_like, or_not_like_before, or_not_like_after
(Flexible Where - Multidimensional Associative array)
$where = array(
'where' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
//'where_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
//'or_where_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
//'where_not_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
//'or_where_not_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
//'or_where' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
//'having' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
//'or_having' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
//'like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'or_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'or_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'or_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'not_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'not_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'not_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'or_not_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'or_not_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
//'or_not_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
);
or
(Key-Value paired - Single Associative array)
$where = array('name' => 'emi', 'email' => 'emi@emi.com' )
or
(String - SQL statement)
$where = 'name = "emi" and email = "emi@emi.com"';
$this->user_model->get_all_rows($where); // without specified table name or
$table = "users";
$this->user_model->get_all_rows($where, false, $table);
-----------------------or---------------------------------
// Example 2 : Using 2nd paramter = Select all fields or certain fields
$fields = 'name, email'; // using string or
$fields = array( 'name','email'); // using index array if not provided, then select * is presumed
$this->user_model->get_all_rows( false, $fields );
-----------------------or---------------------------------
// Example 3 : Using 3rd parameter = table name
$this->user_model->get_all_rows(); // this will select all the data inside user model's table if table did not provided OR
$table = "users";
$this->user_model->get_all_rows( false, false, $table);
-----------------------or---------------------------------
// Example 4 : Using 4th parameter = join single or multiple
// Available join are inner, left, right, left outer, right outer, join, outer, inner
$join = array(
// single table on particular join
'join' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
'inner' => array( 'users_groups' => 'users.id = users_groups.user_id'),
'left' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
'right' => array( 'users_groups' => 'users.id = users_groups.user_id'),
'outer' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
'left outer' => array( 'users_groups' => 'users.id = users_groups.user_id'),
'right outer' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
// multiple table on particular join
'join' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
'inner' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
'left' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
'right' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
'outer' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
'left outer' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
'right outer' => array(
'groups' => 'users_groups.user_id = groups.id',
'users_groups' => 'users.id = users_groups.user_id'
),
);
-----------------------or---------------------------------
// Example 5 : Using 5th parameter = Order by result
$orderBy = 'name asc, id desc'; // or
$orderBy = array( 'name' => 'asc', 'id' => 'desc' );
$this->user_model->get_all_rows( false, false, false, false, $orderBy );
-----------------------or---------------------------------
// Example 6 : Using 6th parameter = group by result
$groupBy = 'name'; // or $groupBy = array( 'name', 'id' );
$this->user_model->get_all_rows( false, false, false, false, false, $groupBy );
-----------------------or---------------------------------
// Example 7 : Using 7th parameter = limit the result
$limit = '20'; // limit only
$limit = [10 => 20]; // limit and offset, key is a limit, values is an offset
$this->user_model->get_all_rows( false, false, false, false, false, false, $limit );
Get ONLY one row from database's table. This method accept various sql keyword to perform any database operation. You can either use all where, join, like, family etc that exist on codeigniter's quiry builder.
Parameters
- All parameters inside @get_all_rows() method are availables here except the first parameter($where) is required, the rest is optional
Return
Array key-valued paired which only returned single row data only. This method identical with get_all_rows() method except this method only returned one row data only.
Update data inside database's table
Parameters
$columnToUpdate
= array REQUIRED. Key-value paired array.$usingCondition
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$tableToUpdate
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
Return 1 if success, 2 if no delete occured, 3 if delete operation can't be done.
$columnToUpdate = array(
'title' => 'My title',
'name' => 'My Name',
'date' => 'My date'
);
$usingCondition = ['id' => 1'];
$this->user_model->update( $columnToUpdate, $usingCondition );
Update data inside database's table
Parameters
$columnToUpdate
= array REQUIRED. Key-value paired array.$usingCondition
= string REQUIRED.$tableToUpdate
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
Return TRUE success, FALSE otherwise.
$columnToUpdate = array(
array(
'id' => '1', // will act as primary key
'name' => 'My Name',
'date' => 'My date'
),
array(
'id' => '2', // will act as primary key
'name' => 'My Name',
'date' => 'My date'
)
);
$usingCondition = 'id';
$this->user_model->update( $columnToUpdate, $usingCondition );
Replacing existing data into the new one. Usually used when mixed with DELETE and INSERT query at the same time.
Parameters
$data
= array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.
Return
Return TRUE success, FALSE otherwise.
// this will find the data with an ID 1, and replacing existing content with new provided content
$data = array(
array(
'id' => '1', // will act as primary key
'name' => 'My Name',
'date' => 'My date'
)
);
$this->user_model->replace( $data );
Get maximun value from certain field/column
Parameters
$fields
= string REQUIRED. Field/column's name$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return single row result array, EMPTY otherwise
// without condition
$fields = 'quantity';
$result = $this->user_model->max( $fields );
-----------------------or------------------------
// with condition
$fields = 'quantity';
$where = ['age' => 50];
$result = $this->user_model->max( $fields, $where );
-----------------------or------------------------
// with table's name
$fields = 'quantity';
$where = ['age' => 50];
$table = 'users_contact';
$result = $this->user_model->max( $fields, $where, $table );
Get minumun value from certain field/column
Parameters
$fields
= string REQUIRED. Field/column's name$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return single row result array, EMPTY otherwise
// without condition
$fields = 'quantity';
$result = $this->user_model->min( $fields );
-----------------------or------------------------
// with condition
$fields = 'quantity';
$where = ['age' => 50];
$result = $this->user_model->min( $fields, $where );
-----------------------or------------------------
// with table's name
$fields = 'quantity';
$where = ['age' => 50];
$table = 'users_contact';
$result = $this->user_model->min( $fields, $where, $table );
Get average value from certain field/column
Parameters
$fields
= string REQUIRED. Field/column's name$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return single row result array, EMPTY otherwise
// without condition
$fields = 'quantity';
$result = $this->user_model->avg( $fields );
-----------------------or------------------------
// with condition
$fields = 'quantity';
$where = ['age' => 50];
$result = $this->user_model->avg( $fields, $where );
-----------------------or------------------------
// with table's name
$fields = 'quantity';
$where = ['age' => 50];
$table = 'users_contact';
$result = $this->user_model->avg( $fields, $where, $table );
Get sum of value from certain field/column
Parameters
$fields
= string REQUIRED. Field/column's name$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return single row result array, EMPTY otherwise
// without condition
$fields = 'quantity';
$result = $this->user_model->sum( $fields );
-----------------------or------------------------
// with condition
$fields = 'quantity';
$where = ['age' => 50];
$result = $this->user_model->sum( $fields, $where );
-----------------------or------------------------
// with table's name
$fields = 'quantity';
$where = ['age' => 50];
$table = 'users_contact';
$result = $this->user_model->sum( $fields, $where, $table );
Get average value from certain field/column
Parameters
$where
= string|array OPTIONAL. Sql string or Key-value paired array or Flexible where condition(See @get_all_rows implementation).$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return integet number. 0 if no data found, 1 or > if found.
// without condition
$this->user_model->count();
-----------------------or------------------------
// with condition
$where = array('id' => 1);
$this->user_model->count( $where );
-----------------------or------------------------
// with table's name
$where = array('id' => 1);
$table = 'groups';
$this->user_model->count( $where, $table );
Get result set of data with AND condition
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$this->user_model->where( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$table = 'users';
$this->user_model->where( $arrValue, $table );
Get result set of data with OR condition
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$this->user_model->or_where( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_where( $arrValue, $table );
Get result set of data with AND condition using having. Identical to @where method
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$this->user_model->having( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$table = 'users';
$this->user_model->having( $arrValue, $table );
Get result set of data with OR condition using having. Identical to @or_where method
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$this->user_model->or_having( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('id !=' => 1, 'email =' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_having( $arrValue, $table );
Get result set of data with AND condition using where in which accept an array as value.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$this->user_model->or_having( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$table = 'users';
$this->user_model->or_having( $arrValue, $table );
Get result set of data with OR condition using where in which accept an array as value.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$this->user_model->or_where_in( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$table = 'users';
$this->user_model->or_where_in( $arrValue, $table );
Get result set of data with AND condition using where not in which accept an array as value.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$this->user_model->where_not_in( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$table = 'users';
$this->user_model->where_not_in( $arrValue, $table );
Get result set of data with OR condition using where not in which accept an array as value.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$this->user_model->or_where_not_in( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] );
$table = 'users';
$this->user_model->or_where_not_in( $arrValue, $table );
Get result set of data with AND condition using like clause with placing % both left and right.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_where_not_in( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_where_not_in( $arrValue, $table );
Get result set of data with AND condition using like clause with placing % only left side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->like_before( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->like_before( $arrValue, $table );
Get result set of data with AND condition using like clause with placing % only right side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->like_after( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->like_after( $arrValue, $table );
Get result set of data with OR condition using like clause with placing % both left and right.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_like( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_like( $arrValue, $table );
Get result set of data with OR condition using like clause with placing % only left side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_like_before( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_like_before( $arrValue, $table );
Get result set of data with OR condition using like clause with placing % only right side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_like_after( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_like_after( $arrValue, $table );
Get result set of data with AND condition using not like clause with placing % both left and right.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->not_like( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->not_like( $arrValue, $table );
Get result set of data with AND condition using not like clause with placing % only left side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->not_like_before( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->not_like_before( $arrValue, $table );
Get result set of data with AND condition using not like clause with placing % only right side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->not_like_after( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->not_like_after( $arrValue, $table );
Get result set of data with OR condition using not like clause with placing % both left and right.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_not_like( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_not_like( $arrValue, $table );
Get result set of data with OR condition using not like clause with placing % only left side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_not_like_before( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_not_like_before( $arrValue, $table );
Get result set of data with OR condition using not like clause with placing % only right side.
Parameters
$arrValue
= string|array REQUIRED. Key-value paired array.$table
= string OPTIONAL. Table's name. If you didn't specified, it'll look at$table
property defined inside the class's model as default.$join
= array OPTIONAL. Implementation could be found on @get_all_rows and @get_specified_row method. The implementation are completely same.
Return
Return array collection of data with more than single rows, EMPTY otherwise
// without table
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$this->user_model->or_not_like_after( $arrValue );
-----------------------or------------------------
// with table's name
$arrValue = array('name' => 'emi', 'email' => 'emi@emi.com' );
$table = 'users';
$this->user_model->or_not_like_after( $arrValue, $table );