File: //var/www/html/qcr24/app/application/models/Mcommon.php
<?php
class Mcommon extends CI_Model {
function __construct(){
parent::__construct();
}
public function insert($table,$data){
$this->db->insert($table,$data);
return $this->db->insert_id();
}
public function batch_insert($table,$data){
$this->db->insert_batch($table,$data);
return 1;
}
public function getDetails($table,$condition){
$this->db->where($condition);
$query=$this->db->get($table);
// echo $this->db->last_query();die;
return $query->result_array();
}
public function getRow($table,$condition){
$this->db->where($condition);
$query=$this->db->get($table);
return $query->row_array();
}
public function checkUser($table,$condition){
$this->db->where($condition);
$query=$this->db->get($table);
return $query->row_array();
}
public function update($table,$condition,$data){
$this->db->where($condition);
$this->db->update($table,$data);
//echo $this->db->last_query();die;
return 1;
}
public function delete($table,$condition){
$this->db->where($condition);
$this->db->delete($table);
return 1;
}
public function getFullDetails($table){
$query=$this->db->get($table);
return $query->result_array();
}
public function user_check($table,$email, $password) {
$this->db->select('*');
$this->db->from($table);
$this->db->where(array('email' => $email, 'password' => md5($password)));
$query = $this->db->get();
return $query->row_array();
}
public function getDetailsFiltered($table,$params){
$this->db->from($table);
if(!empty($params['date_min']))
{
$this->db->where('date_of_creation >', $params['date_min']);
}
if(!empty($params['date_max']))
{
$stop_date = date('Y-m-d', strtotime($params['date_max'].' +1 day'));
$this->db->where('date_of_creation <=', $stop_date);
}
$query=$this->db->get();
return $query->result_array();
}
}