| Server IP : 68.178.202.69 / Your IP : 216.73.216.122 Web Server : Apache System : Linux 69.202.178.68.host.secureserver.net 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64 User : ikioworld ( 1005) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/ikioworld/www/application/models/ |
Upload File : |
<?php
class Newsmodel extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->table_name = 'news';
}
function add($data){
if(!empty($data)){
// print_r($data);exit;
unset($data['sbt']);
unset($data['news_color']);
unset($data['news_size']);
unset($data['news_material']);
unset($data['news_images']);
$this->db->insert($this->table_name,$data);
$insert_id = $this->db->insert_id();
return $insert_id;
// echo $this->db->last_query(); die;
}
}
function edit($id,$data){
if(!empty($data) && $id!=''){
unset($data['sbt']);
unset($data['news_color']);
unset($data['news_size']);
unset($data['news_material']);
unset($data['news_images']);
$this->db->where('id',$id);
return $this->db->update($this->table_name,$data);
//echo $this->db->last_query(); die;
}
}
function fetch_details($id){
if($id!=''){
$this->db->select('*');
$this->db->from('news');
$this->db->where('news.id',$id);
$query = $this->db->get();
return $query->row();
}
}
function get_total_records(){
return $query = $this->db->count_all_results($this->table_name);
}
function get_contents($start, $limit){
$this->db->select('*');
$this->db->order_by($this->table_name.".id", "desc");
$query = $this->db->get($this->table_name);
return $query->result();
}
function deletenews($id){
$this->db->where('id', $id);
$this->db->delete($this->table_name);
}
function deleteallnews($id){
$this->db->where('id', $id);
$this->db->delete('news_images');
}
function getAllCategories()
{
$query = $this->db->get('category');
return $query->result();
}
function fetch_subcategory($item_id)
{
$this->db->where('category_type', $item_id);
$this->db->order_by('name', 'ASC');
$query = $this->db->get('subcategory');
$output = '<option value="">Select Sub Category</option>';
foreach($query->result() as $row)
{
$output .= '<option value="'.$row->subcategory_id.'">'.$row->subcategory_name.'</option>';
}
return $output;
}
function get_category(){
$this->db->select('*');
$query = $this->db->get('category');
return $query->result();
}
function get_subcategory($item_id){
if($item_id!=''){
$this->db->select('*');
$this->db->order_by("name", "ASC");
$query = $this->db->where('category_type',$item_id);
$query = $this->db->get('subcategory');
return $query->result();
}
}
function getNews()
{
$this->db->select('*');
$this->db->select('news.slug as newsID');
$this->db->select('news_images.features');
$this->db->from('news');
$this->db->join('news_images',"news.id=news_images.news_id and news_images.features='yes'");
$this->db->where("news.status='active'");
$query = $this->db->get();
return $query->result();
}
function getFeaturedNews()
{
$this->db->select('*');
$this->db->select('news.slug as newsID');
$this->db->select('news_images.features');
$this->db->from('news');
$this->db->join('news_images',"news.id=news_images.news_id and news_images.features='yes'");
$this->db->where("news.status='active'");
$this->db->where("news.is_featured='yes'");
$this->db->order_by("news.id", "desc");
$query = $this->db->get();
return $query->result();
}
function getLinkdln()
{
$this->db->select('*');
$this->db->from('linkdln');
$this->db->where("linkdln.status='active'");
$this->db->order_by("linkdln.id", "desc");
$this->db->limit(3);
$query = $this->db->get();
return $query->result();
}
function get_details($slug){
$this->db->select('news.*');
$this->db->select('news.featured_image as image');
$this->db->from('news');
$this->db->where('news.slug',$slug);
$query = $this->db->get();
return $query->result();
}
function get_Related($id){
$this->db->select('news.*');
$this->db->select('news.featured_image as image');
$this->db->from('news');
$this->db->where('news.id !=',$id);
$query = $this->db->get();
return $query->result();
}
function count_feature_news($news_id){
$this->db->where('news_id',$news_id);
$this->db->where('features','yes');
return $query = $this->db->count_all_results('news_images');
}
function get_export_data(){
$this->db->select(['sku','news_name','news_tagline','news_short_description','news_long_description','heading1','data1','heading2','data2','heading3','data3','heading4','data4','heading5','data5','heading6','data6','heading7','data7','heading8','data8','heading9','data9','heading10','data10','heading11','data11','heading12','data12','heading13','data13','heading14','data14','heading15','data15','heading16','data16','document','tags']);
$this->db->order_by($this->table_name.".id", "desc");
$query = $this->db->get($this->table_name);
return $query->result_array();
}
function make_query()
{
$query = "
SELECT news.*,news.slug as newsID,news.featured_image as image FROM news where news.status='active' ORDER BY news.id desc";
return $query;
}
function count_all()
{
$query = $this->make_query();
$data = $this->db->query($query);
return $data->num_rows();
}
function fetch_data($limit,$start)
{
$query = $this->make_query();
$query .= ' LIMIT '.$start.', ' . $limit;
$data = $this->db->query($query);
$output = '';
if($data->num_rows() > 0)
{
foreach($data->result_array() as $row)
{
$project_id = $row['newsID'];
$project_name =$row['news_name'];
$item_name = $row['news_short_description'];
$date = $row['updated_at'];
$dateToPrint = date('j F, Y', strtotime($date) ) ;
$output.='
<div class="col-md-4">
<div class="ikio_blogListing__wrap">
<div class="ikio_blogLising__image">
<a href='.base_url().'industry-news/'.$project_id.'><img src='.base_url().'uploads/news/'. $row['image'] .'></a>
</div>
<div class="ikio__blogListing--content">
<div class="row">
<div class="blog_Content" id="lates_newsContent">
<a href='.base_url().'industry-news/'.$project_id.'>
<h6>'.$project_name.'</h6>
</a>
<a href='.base_url().'industry-news/'.$project_id.' class="button_underline" id="hsize14">Read More</a>
</div>
</div>
</div>
</div>
</div>
';
}
}
else
{
$output = '<img src="'.base_url().'assets/img/404.jpg" class="no_data">';
}
return $output;
}
function delete_news($id)
{
$this->db->where('id', $id);
$this->db->delete('news');
}
function make_featured($id)
{
$this->db->set('is_featured','yes');
$this->db->where('id', $id);
$this->db->update('news');
}
function remove_featured($id)
{
$this->db->set('is_featured','no');
$this->db->where('id', $id);
$this->db->update('news');
}
function make_activated($id)
{
$this->db->set('status','active');
$this->db->where('id', $id);
$this->db->update('news');
}
function remove_activated($id)
{
$this->db->set('status','inactive');
$this->db->where('id', $id);
$this->db->update('news');
}
}