| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/thegioimaycongnghiep.vn/public_html/site/components/errcode/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Errcode_model extends CI_Model
{
function __construct(){
parent::__construct();
}
//error list
function get_errcode($modern_id, $num=20, $start=0)
{
$this->db->where('modern_id', $modern_id) ;
$this->db->where('bl_active', 1) ;
$this->db->order_by('err_code','asc');
$query = $this->db->get('errcode', $num, $start);
return $query->result() ;
}
function count_errcode($modern_id)
{
$this->db->where('modern_id', $modern_id) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get('errcode');
return $query->num_rows() ;
}
//get modern
function get_modern($id, $num=20, $start=0)
{
$this->db->where('trade_id', $id) ;
$this->db->where('bl_active', 1) ;
$this->db->order_by('lb_name','asc');
$query = $this->db->get('modern', $num, $start);
return $query->result() ;
}
function count_modern($id)
{
$this->db->where('trade_id', $id) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get('modern');
return $query->num_rows() ;
}
//tim kiem tu khoa
function get_search($keys, $num=20, $start=0)
{
$this->db->where("(err_code LIKE '%".$keys."%' OR lb_display LIKE '%".$keys."%' OR lb_causes LIKE '%".$keys."%' OR lb_remedy LIKE '%".$keys."%')", NULL, FALSE) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get('errcode', $num, $start);
return $query->result();
}
function count_search($keys)
{
$this->db->where("(err_code LIKE '%".$keys."%' OR lb_display LIKE '%".$keys."%' OR lb_causes LIKE '%".$keys."%' OR lb_remedy LIKE '%".$keys."%')", NULL, FALSE) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get('errcode');
return $query->num_rows() ;
}
function search_modern($keys='', $num=20, $start=0)
{
$this->db->like('lb_name', $keys) ;
$this->db->where('bl_active', 1) ;
$this->db->order_by('lb_name','asc');
$query = $this->db->get('modern', $num, $start);
return $query->result() ;
}
function count_search_modern($keys='')
{
$this->db->like('lb_name', $keys) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get('modern');
return $query->num_rows() ;
}
//
function get_all($tbl, $num=20, $start=0)
{
$this->db->where('bl_active', 1);
$query = $this->db->get($tbl, $num, $start);
return $query->result();
}
function count_all($tbl)
{
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->num_rows() ;
}
function get_id($tbl, $name, $id)
{
if($id) $this->db->where($name, $id) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->row() ;
}
function save($tbl, $data, $id=0, $name='')
{
if($id)
{
$this->db->where($name, $id) ;
return $this->db->update($tbl, $data);
}
else
{
$this->db->insert($tbl,$data) ;
return $this->db->insert_id();
}
}
function del($tbl, $id, $name)
{
if($id){
$this->db->where($name, $id) ;
$this->db->delete($tbl) ;
}
}
function trash($tbl, $id, $name)
{
if($id){
$this->db->where($name, $id);
return $this->db->update($tbl, array('bl_active'=>-1));
}
}
function restore($tbl, $id, $name)
{
if($id){
$this->db->where($name, $id);
return $this->db->update($tbl, array('bl_active'=>1));
}
}
function remove($tbl)
{
$date = new DateTime();
$date->modify('-3 month');
$date_del = $date->format('Y-m-d H:i:s');
$this->db->where('bl_active', -1);
$this->db->where('dt_create <', $date_del);
if($this->db->delete($tbl)){
return true;
}else{
return false;
}
}
function get_result($tbl, $num=10, $start=0, $wh='', $value=0)
{
if($wh) $this->db->where($wh, $value) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl, $num, $start);
return $query->result() ;
}
function get_where($tbl, $wh='', $value=0, $num=100, $start=0, $order='')
{
if($wh) $this->db->where($wh, $value) ;
if($order) $this->db->order_by($order, 'DESC') ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl, $num, $start);
return $query->result() ;
}
function count_where($tbl, $where='', $id=0)
{
if($where) $this->db->where($where, $id) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->num_rows() ;
}
function get_name($tbl, $field, $wh='', $value=0)
{
$this->db->select($field) ;
if($wh) $this->db->where($wh, $value) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->row() ;
}
function get_field($tbl, $field, $wh='', $value=0)
{
$this->db->select($field) ;
if($wh) $this->db->where($wh, $value) ;
$this->db->where('bl_active', 1) ;
$rs = $this->db->get($tbl)->row();
if($rs)
return $rs->$field ;
else
return ;
}
}
?>