| 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/hocthongminh.net-bk/public_html/site/components/news/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class News_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function get_row($tbl,$name,$id)
{
$this->db->where($name,$id);
$this->db->where('bl_active',1);
$query = $this->db->get($tbl);
return $query->row();
}
function count_all()
{
$this->db->where('news.bl_active',1);
$query = $this->db->get("news");
return $query->num_rows();
}
function get_id($id)
{
$this->update_view($id) ;
$this->db->where('news_id', $id);
$this->db->where('bl_active',1);
$query = $this->db->get("news");
return $query->row();
}
function update_view($id=0)
{
$sql="update news set nb_view=(nb_view+1) where news_id='".$id."'" ;
$this->db->query($sql);
return ;
}
//*********** sản phẩm ***********************
function get_product($num=20,$start=0,$catid=0)
{
$this->db->where('bl_active',1);
if($catid) $this->db->where('catid',$catid);
$query = $this->db->get("product", $num, $start);
return $query->result();
}
/**
* Ver : 1.0
* Date : 10-10-2020
* Desc : Lấy ads sản phẩm chèn vào trang tin tức
* Params : list prodi
* Return :
*/
function get_product_ads($list_proid)
{
$list_proid = explode(",",$list_proid);
$this->db->where('bl_active',1);
$this->db->where_in('proid',$list_proid);
$query = $this->db->get("product");
return $query->result();
}
function category_product($num=20,$start=0,$catid=0)
{
$this->db->where('bl_active',1);
$this->db->where('parent_id',0);
if($catid) $this->db->where('catid',$catid);
$query = $this->db->get("category", $num, $start);
return $query->result();
}
function get_catid($catid, $num=20, $start=0)
{
$this->db->where('bl_active',1);
$this->db->where('cat_id',$catid);
$this->db->order_by('dt_modify','DESC');
$query = $this->db->get("news", $num, $start);
return $query->result();
}
function count_newsest()
{
$this->db->where('bl_active',1);
$this->db->where('is_hot',1);
$query = $this->db->get("news");
return $query->num_rows();
}
function get_newsest($num=9,$offset=0)
{
$this->db->where('bl_active',1);
$this->db->where('is_hot',1);
$this->db->order_by('dt_create','DESC');
return $this->db->get('news',$num, $offset)->result();
}
function get_newsest_cate($catid, $num, $offset)
{
$this->db->where('bl_active',1);
$this->db->where('cat_id',$catid);
$this->db->order_by('dt_create','DESC');
return $this->db->get('news',$num, $offset)->result();
}
function get_list_sub($catid=0, $display=10)
{
if($catid) $this->db->where('cat_id', $catid);
$this->db->order_by("dt_create", "DESC") ;
$this->db->where('bl_active',1);
$query = $this->db->get("news", $display);
return $query->result();
}
function tin_xem_nhieu($num, $offset)
{
$this->db->where('bl_active',1);
$this->db->order_by("nb_view", "DESC") ;
$query = $this->db->get("news",$num, $offset);
return $query->result();
}
//****************** category_news ******************************
function category_top()
{
$this->db->where('parent_id',0);
$this->db->where('bl_active',1);
$this->db->order_by("nb_order", "ASC") ;
$query = $this->db->get("news_category");
return $query->result();
}
function get_subcategory($catid)
{
$this->db->where('parent_id', $catid);
$this->db->where('bl_active',1);
$this->db->order_by("cat_name", "ASC") ;
$query = $this->db->get("news_category");
return $query->result();
}
}
?>