|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/laciasmara.com/public_html/shop/application/models/ |
Upload File : |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Banner_m extends MY_Model
{
protected $_table_name = 'carousel_banners';
protected $_primary_key = 'carousel_banner_id';
protected $_order_by = 'carousel_banner_id';
function __construct()
{
parent::__construct();
}
public function get_all_banners()
{
$this->db->select('*');
$this->db->from('carousel_banners');
$this->db->where('deleted_at IS NULL', null, false);
$this->db->order_by('is_active', 'DESC');
$this->db->order_by('order_number', 'ASC');
$query = $this->db->get();
return $query->result();
}
public function get_all_flying_banners()
{
$this->db->select('*');
$this->db->from('top_banners');
$this->db->order_by('is_active', 'DESC');
$this->db->where('deleted_at IS NULL', null, false);
$this->db->order_by('order_number', 'ASC');
$query = $this->db->get();
return $query->result();
}
public function get_banner_by_id($id)
{
$this->db->select('*');
$this->db->from('carousel_banners');
$this->db->where('carousel_banner_id', $id);
$this->db->where('deleted_at IS NULL', null, false);
$query = $this->db->get();
return $query->row();
}
public function get_flying_banner_by_id($id)
{
$this->db->select('*');
$this->db->from('top_banners');
$this->db->where('banner_id', $id);
$query = $this->db->get();
return $query->row();
}
public function update_order($id, $order_number)
{
$this->db->where('carousel_banner_id', $id);
return $this->db->update('carousel_banners', [
'order_number' => $order_number,
'updated_at' => date('Y-m-d H:i:s')
]);
}
public function update_flying_banner_order($id, $order_number)
{
$this->db->where('banner_id', $id);
return $this->db->update('top_banners', [
'order_number' => $order_number,
'updated_at' => date('Y-m-d H:i:s')
]);
}
public function get_max_order()
{
$this->db->select_max('order_number');
$query = $this->db->get('carousel_banners');
$result = $query->row();
return $result->order_number ?? 0;
}
public function get_max_flying_order()
{
$this->db->select_max('order_number');
$query = $this->db->get('top_banners');
$result = $query->row();
return $result->order_number ?? 0;
}
}