| 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/galaxynail.com/site/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Booking_model extends CI_Model
{
function __construct(){
parent::__construct();
}
function get_all($tbl, $num=20, $start=0)
{
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl, $num, $start);
return $query->result() ;
}
function count_all($tbl)
{
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->num_rows() ;
}
function get_id($tbl, $name, $id)
{
if($id) $this->db->where($name, $id) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->row() ;
}
function save($tbl, $data, $id=0, $name='')
{
if($id)
{
$this->db->where($name, $id) ;
return $this->db->update($tbl, $data);
}
else
{
$this->db->insert($tbl,$data) ;
return $this->db->insert_id();
}
}
function del($tbl, $id, $name)
{
if($id){
$this->db->where($name, $id) ;
$this->db->delete($tbl) ;
}
}
function trash($tbl, $id, $name)
{
if($id){
$this->db->where($name, $id);
return $this->db->update($tbl, array('bl_active'=>-1));
}
}
function restore($tbl, $id, $name)
{
if($id){
$this->db->where($name, $id);
return $this->db->update($tbl, array('bl_active'=>1));
}
}
function remove($tbl)
{
$date = new DateTime();
$date->modify('-3 month');
$date_del = $date->format('Y-m-d H:i:s');
$this->db->where('bl_active', -1);
$this->db->where('dt_create <', $date_del);
if($this->db->delete($tbl)){
return true;
}else{
return false;
}
}
function get_result($tbl, $num=10, $start=0, $wh='', $value=0)
{
if($wh) $this->db->where($wh, $value) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl, $num, $start);
return $query->result() ;
}
function get_where($tbl, $wh='', $value=0, $num=100, $start=0, $order='')
{
if($wh) $this->db->where($wh, $value) ;
if($order) $this->db->order_by($order, 'DESC') ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl, $num, $start);
return $query->result() ;
}
function count_where($tbl, $where='', $id=0)
{
if($where) $this->db->where($where, $id) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->num_rows() ;
}
function get_name($tbl, $field, $wh='', $value=0)
{
$this->db->select($field) ;
if($wh) $this->db->where($wh, $value) ;
$this->db->where('bl_active', 1) ;
$query = $this->db->get($tbl);
return $query->row() ;
}
function get_field($tbl, $field, $wh='', $value=0)
{
$this->db->select($field) ;
if($wh) $this->db->where($wh, $value) ;
$this->db->where('bl_active', 1) ;
$rs = $this->db->get($tbl)->row();
if($rs)
return $rs->$field ;
else
return ;
}
}
?>