| Server IP : 103.48.194.25 / Your IP : 216.73.216.231 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/khonguyenlieu.vn/public_html/site/models/ |
Upload File : |
<? if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class home_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function get_cat_home($num=6,$start=0)
{
$this->db->where('IsHome',1) ;
$this->db->where('bl_active',1) ;
$this->db->order_by('Ordering','asc') ;
$query = $this->db->get('category', $num, $start) ;
return $query->result() ;
}
function cat_detail($CategoryID)
{
$this->db->where('bl_active',$CategoryID) ;
$this->db->where('bl_active',1) ;
$this->db->order_by('Ordering','asc') ;
$query = $this->db->get('category') ;
return $query->row() ;
}
function get_all($num=20,$start=0,$cat=0)
{
$arr = $this->get_subcat($cat) ;
if($arr) $this->db->where_in('CategoryID',$arr) ;
elseif($cat) $this->db->where('CategoryID',$cat) ;
$this->db->where('IsHome',1) ;
$this->db->where('bl_active',1) ;
$this->db->order_by('Ordering','asc') ;
$query = $this->db->get('product', $num, $start) ;
return $query->result() ;
}
function count_all()
{
$this->db->where('bl_active',1) ;
$query = $this->db->get('product') ;
return $query->num_rows() ;
}
function get_subcat($catid)
{
$ar_id = array($catid);
$list = $this->get_record('category',array('ParentID'=>$catid));
if($list){
foreach($list as $rs):
array_push($ar_id,$rs->CategoryID);
$list1 = $this->get_record('category',array('ParentID'=>$rs->CategoryID));
if($list1){
foreach($list1 as $rs1):
array_push($ar_id,$rs1->CategoryID);
$list2 = $this->get_record('category',array('ParentID'=>$rs1->CategoryID));
if($list2){
foreach($list2 as $rs2):
array_push($ar_id,$rs2->CategoryID);
endforeach;
}
endforeach;
}
endforeach;
}
return $ar_id;
}
function get_record($tbl,$arr)
{
foreach($arr as $k => $v) {
$this->db->where($k, $v);
}
$this->db->where('bl_active',1) ;
$query = $this->db->get($tbl) ;
return $query->result() ;
}
function get_id($id)
{
$this->db->where('ProductID',$id) ;
$this->db->where('bl_active',1) ;
$query = $this->db->get('product') ;
return $query->row() ;
}
function get_product_img($id, $num=5,$start=0)
{
$this->db->where('ProductID',$id) ;
$query = $this->db->get('productimage', $num, $start=0) ;
return $query->result() ;
}
function get_product_category($catid, $num=20,$start=0)
{
$this->db->where('bl_active',1) ;
$this->db->where('CategoryID',$catid) ;
$this->db->order_by('ProductStatus','ASC') ;
$this->db->order_by('Ordering','ASC') ;
$query = $this->db->get('product', $num, $start) ;
return $query->result() ;
}
}
?>