| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 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/pundarikanail.com-bk/wadmin/components/gallery/models/ |
Upload File : |
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Gallery_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function get_all_gallery($num=20,$offset=0)
{
$this->db->order_by('dt_create','desc');
$query = $this->db->get('gallery',$num,$offset);
return $query->result();
}
function count_all_gallery()
{
$query = $this->db->get('gallery');
return $query->num_rows();
}
function get_id($id=0)
{
$this->db->where('gallery_id',$id);
$query = $this->db->get('gallery');
return $query->row();
}
function get_gallery_active($num=20,$offset=0)
{
$this->db->where('bl_active',1);
$this->db->order_by('dt_create','desc');
$query = $this->db->get('gallery',$num,$offset);
return $query->result();
}
function get_gallery_category()
{
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('gallery_category');
return $query->result();
}
function get_gallery_active_by_cat($catid=0)
{
$this->db->where('gcat_id',$catid);
$this->db->where('bl_active',1);
$this->db->order_by('nb_order','ASC');
$query = $this->db->get('gallery');
return $query->result();
}
//Save tour
function save($data,$id=0)
{
if($id)
{
$this->db->where('gallery_id',$id);
if($this->db->update('gallery',$data)){
return true;
}else{
return false;
}
}
else
{
if($this->db->insert('gallery',$data))
{
return true;
}else{
return false;
}
}
}
function del($id)
{
$this->delimg($id); //Xóa file hình ảnh
$this->db->where('gallery_id',$id);
if($this->db->delete('gallery')){
return true;
}else{
return false;
}
}
function delimg($id)
{
$rs = $this->get_id($id);
if($rs)
{
if($rs->lb_url && file_exists(ROOT_IMG.'gallery/large/'.$rs->lb_url)){
@unlink(ROOT_IMG.'gallery/large/'.$rs->lb_url);
@unlink(ROOT_IMG.'gallery/small/'.$rs->lb_url);
}
}
}
}
?>