| Server IP : 103.48.194.25 / Your IP : 216.73.216.74 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 : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/namduongmarket.com-bk/public_html/site/components/home/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home_model extends CI_Model
{
function __construct(){
parent::__construct();
}
function product_promo($num=8,$start=0)
{
$this->db->where('bl_active',1) ;
//$this->db->where('is_home', 1) ;
//$this->db->where('is_promo', 1) ;
//$this->db->order_by('nb_order','ASC') ;
$query = $this->db->get('product', $num, $start) ;
return $query->result() ;
}
function get_category_home($num=20,$start=0)
{
$this->db->where('bl_active',1);
//$this->db->where('parent_id',0) ;
$this->db->where('is_home',1) ;
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('category',$num,$start);
return $query->result() ;
}
function lit_subcat($catid,$num=3,$start=0)
{
$this->db->where('parent_id',$catid);
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('category',$num,$start);
return $query->result();
}
function get_childcat($catid,$num=3,$start=0)
{
$arr_cat = $this->get_subcat($catid);
$this->db->where_in('parent_id',$arr_cat);
$this->db->where('is_home',1);
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('category',$num,$start);
return $query->result();
}
function get_product_home($catid=1,$num=10,$start=0)
{
$arr = array();
$rs = $this->get_id('category','catid',$catid);
switch($rs->nb_level)
{
case 0 :
$arr = $this->get_subcat($catid);
$this->db->where_in('catid', $arr);
break ;
case 1 :
$arr = $this->get_subcat($catid);
$this->db->where_in('catid', $arr);
break ;
case 2 :
$this->db->where('catid',$catid);
break ;
}
$this->db->where('is_home',1);
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC') ;
$query = $this->db->get('product', $num, $start) ;
return $query->result() ;
}
function get_subcat($catid)
{
$ar_id = array($catid);
$list = $this->get_record('category',array('parent_id'=>$catid,'bl_active'=>1));
if($list){
foreach($list as $rs):
array_push($ar_id,$rs->catid);
$list1 = $this->get_record('category',array('parent_id'=>$rs->catid,'bl_active'=>1));
if($list1){
foreach($list1 as $rs1):
array_push($ar_id,$rs1->catid);
$list2 = $this->get_record('category',array('parent_id'=>$rs1->catid,'bl_active'=>1));
if($list2){
foreach($list2 as $rs2):
array_push($ar_id,$rs2->catid);
endforeach;
}
endforeach;
}
endforeach;
}
return $ar_id;
}
//tin tuc tren góc phải
function get_home_news()
{
//$this->db->where('cat_id',3);
//$this->db->order_by('nb_order','ASC');
$this->db->where('is_home',1);
$this->db->where('bl_active',1);
$this->db->order_by('dt_modify','desc');
$query = $this->db->get("news",6,0);
return $query->result() ;
}
//chua dung
function get_product_category($catid, $num=20,$start=0)
{
$arr = $this->get_subcat($catid);
$this->db->where_in('catid', $arr) ;
$this->db->where('bl_active',1) ;
$this->db->order_by('nb_order','ASC') ;
$query = $this->db->get('product', $num, $start) ;
return $query->result() ;
}
function count_product_category($catid)
{
$arr = $this->get_subcat($catid);
$this->db->where_in('catid', $arr) ;
$this->db->where('bl_active',1) ;
$this->db->order_by('nb_order','ASC') ;
$query = $this->db->get('product') ;
return $query->num_rows() ;
}
function get_all($num=20,$start=0)
{
$this->db->where('bl_active',1) ;
$this->db->order_by('nb_order','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_id($tbl,$name,$id)
{
$this->db->where($name,$id) ;
$this->db->where('bl_active',1) ;
$query = $this->db->get($tbl) ;
return $query->row() ;
}
function get_record($tbl,$arr)
{
foreach($arr as $k => $v) {
$this->db->where($k, $v);
}
$query = $this->db->get($tbl) ;
return $query->result() ;
}
//load main cate cho cuoi trang
function get_maincat($num=20, $start=0)
{
$this->db->where('bl_active',1);
$this->db->where('parent_id',0) ;
//$this->db->where('is_home',1) ;
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('category', $num, $start) ;
return $query->result() ;
}
//Load banner
function slidehome($num=5, $offset=0)
{
$this->db->where('bl_active',1) ;
$this->db->order_by('BannerID','DESC');
return $this->db->get('productbanner', $num, $offset)->result();
}
function get_bn_home_full()
{
$this->db->where('kind','1200x90') ;
$this->db->where('bl_active',1) ;
$query = $this->db->get('banner') ;
return $query->row() ;
}
function get_banner_doitac($kind)
{
$this->db->where('bl_active',1);
$this->db->where('kind',$kind);
return $this->db->get('banner')->result();
}
}
?>