| 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/search/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Search_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
/*function get_product($list_proid='',$num=15,$start=0)
{
$this->db->where_in('proid', $list_proid);
$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($list_proid='')
{
$this->db->where_in('proid', $list_proid);
$this->db->where('bl_active',1);
$query = $this->db->get('product');
return $query->num_rows() ;
}*/
function get_listid($keyword)
{
$this->db->where('keyname',$keyword);
$query = $this->db->get('keywords');
$rs = $query->row();
return $rs ;
}
function get_alias($alias)
{
$this->db->where('bl_active',1);
$this->db->where('alias',$alias);
$query = $this->db->get('keywords');
return $query->row() ;
}
//tìm kiếm theo từ khóa
function search_keyword($keyword,$type='product',$num=16,$start=0)
{
if($type=='product')
$sql="select * from product where pro_name like '%".$keyword."%' OR pro_desc like '%".$keyword."%' OR metakey like '%".$keyword."%' limit $start,$num";
$query = $this->db->query($sql);
return $query->result();
}
function count_keyword($keyword,$type='product')
{
if($type=='product')
$sql="select * from product where pro_name like '%".$keyword."%' OR pro_desc like '%".$keyword."%' OR metakey like '%".$keyword."%'";
$query = $this->db->query($sql);
return $query->num_rows();
}
//tìm kiếm tin tức
function news_keyword($keyword)
{
$sql="select * from news where lb_title like '%".$keyword."%' OR lb_content like '%".$keyword."%' OR metakey like '%".$keyword."%'";
$query = $this->db->query($sql);
return $query->result();
}
//tim kiem
function get_search($list_proid='',$catid=0,$num=15,$start=0)
{
if($catid)
{
$arr = $this->search_category($catid);
$this->db->where_in('catid', $arr);
}
$this->db->where_in('proid', $list_proid);
$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_search($list_proid='',$catid=0)
{
if($catid)
{
$arr = $this->search_category($catid);
$this->db->where_in('catid', $arr);
}
$this->db->where_in('proid', $list_proid);
$this->db->where('bl_active',1);
$query = $this->db->get('product');
return $query->num_rows() ;
}
/*function get_listid($keyword)
{
$this->db->where('keyname',$keyword);
$query = $this->db->get('keywords');
$rs = $query->row();
return $rs ;
}*/
//tim kiem tin tức
function get_news($list_proid='',$num=15,$start=0)
{
$this->db->where_in('news_id', $list_proid);
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('news',$num,$start);
return $query->result() ;
}
function count_news($list_proid='')
{
$this->db->where_in('news_id', $list_proid);
$this->db->where('bl_active',1);
$query = $this->db->get('news');
return $query->num_rows() ;
}
//tim kiem theo ngành nghề
function search_category($catid)
{
$arr = array($catid);
$this->db->like('parent_id',$catid);
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('category');
$list = $query->result();
foreach ($list as $rs):
array_push($arr,$rs->catid);
endforeach ;
return $arr;
}
}
?>