| 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/khonguyenlieu.vn/public_html/site/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class news_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
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 ;
}
function get_catid($catid, $num=20, $start=0)
{
$this->db->where('bl_active',1);
$this->db->where('category_id',$catid);
$query = $this->db->get("news", $num, $start);
return $query->result();
}
function count_all_catid($catid)
{
$this->db->where('bl_active',1);
$this->db->where('category_id',$catid);
$query = $this->db->get("news");
return $query->num_rows();
}
function get_newsest($num, $offset)
{
$this->db->where('bl_active',1);
$this->db->where('is_home',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('category_id',$catid);
$this->db->order_by('dt_create','DESC');
return $this->db->get('news',$num, $offset)->result();
}
function get_list_sub($category_id,$display=10)
{
$this->db->where('category_id', $category_id);
$this->db->order_by("dt_create", "DESC") ;
$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);
$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("lb_category", "ASC") ;
$query = $this->db->get("news_category");
return $query->result();
}
function get_category_detail($catid=0)
{
$this->db->where('category_id',$catid);
$this->db->where('bl_active',1);
$query = $this->db->get("news_category");
return $query->row();
}
function list_product()
{
$this->db->where('IsHome', 1);
$this->db->where('bl_active',1);
$this->db->order_by("LastUpdate", "DESC") ;
$query = $this->db->get("product",8,0);
return $query->result();
}
}
?>