%PDF-1.4
Directory : /var/www/vhosts/lautnusantara.com/httpdocs/web/app/Models/ |
<?php namespace App\Models; use CodeIgniter\Model; class Video_Model extends Model { protected $table = 'ssn_news_items_video'; protected $primaryKey = 'id'; public function get_data_video($id = false, $catid = false, $keyword = false, $limit = false) { $builder = $this->select('ssn_news_items_video.* ,ssn_users.first_name,ssn_users.last_name, ,ssn_news_categories_video.name as categori_name ,ssn_news_categories_video.description as cat_desc'); $builder->join('ssn_users', 'ssn_news_items_video.created_by=ssn_users.id', 'left'); $builder->join('ssn_news_categories_video', 'ssn_news_items_video.catid=ssn_news_categories_video.id', 'left'); if ($id != false) { $builder->where('ssn_news_items_video.id', $id); } if ($catid != false) { $builder->where('ssn_news_items_video.catid', $catid); } $builder->where('ssn_news_items_video.published', '1') ->where('ssn_news_items_video.active', '1') ->where('ssn_news_items_video.trash', '0') ->where('ssn_news_items_video.publish_up <=', date('Y-m-d H:i:s')); if ($keyword != null) { $builder->like('title', $keyword) // ->orLike('introtext', $keyword) // ->orLike('fulltexts', $keyword) ->orLike('metadesc', $keyword) ->orLike('metadata', $keyword) ->orLike('metakey', $keyword) ->orLike('ssn_news_categories_video.name', $keyword) ->groupBy('title') ->having('ssn_news_items_video.publish_up <=', date('Y-m-d H:i:s')) ->having('ssn_news_items_video.published', '1') ->having('ssn_news_items_video.active', '1') ->having('ssn_news_items_video.trash', '0'); if ($catid != null) { $builder->having('ssn_news_items_video.catid', $id); } } if ($limit != false) { $builder->limit($limit); } $builder->orderBy('ssn_news_items_video.publish_up', 'DESC'); return $builder; } public function get_data_video_populer($id = false, $catid = false, $keyword = false, $limit = false) { $builder = $this->select('ssn_news_items_video.* ,ssn_users.first_name,ssn_users.last_name, ,ssn_news_categories_video.name as categori_name ,ssn_news_categories_video.description as cat_desc'); $builder->join('ssn_users', 'ssn_news_items_video.created_by=ssn_users.id', 'left'); $builder->join('ssn_news_categories_video', 'ssn_news_items_video.catid=ssn_news_categories_video.id', 'left'); if ($id != false) { $builder->where('ssn_news_items_video.id', $id); } if ($catid != false) { $builder->where('ssn_news_items_video.catid', $catid); } $builder->where('ssn_news_items_video.published', '1') ->where('ssn_news_items_video.active', '1') ->where('ssn_news_items_video.trash', '0') ->where('ssn_news_items_video.publish_up <=', date('Y-m-d H:i:s')); if ($keyword != null) { $builder->like('title', $keyword) // ->orLike('introtext', $keyword) // ->orLike('fulltexts', $keyword) ->orLike('metadesc', $keyword) ->orLike('metadata', $keyword) ->orLike('metakey', $keyword) ->orLike('ssn_news_categories_video.name', $keyword) ->groupBy('title') ->having('ssn_news_items_video.publish_up <=', date('Y-m-d H:i:s')) ->having('ssn_news_items_video.published', '1') ->having('ssn_news_items_video.active', '1') ->having('ssn_news_items_video.trash', '0'); if ($catid != null) { $builder->having('ssn_news_items_video.catid', $id); } } if ($limit != false) { $builder->limit($limit); } $builder->orderBy('ssn_news_items_video.hits', 'DESC'); return $builder; } public function get_name_kategori_video($catid = false) { $builder = $this->db->table('ssn_news_categories_video'); $builder->select('name'); $builder->where('id', $catid); return $builder->get(); } // tags public function get_tags_by_artikel($itemsid) { $builder = $this->db->table('ssn_news_tags_xref_video'); $builder->select('ssn_news_tags_xref_video.*,ssn_news_tags_video.name'); $builder->join('ssn_news_tags_video', 'ssn_news_tags_video.id=ssn_news_tags_xref_video.tag_id', 'left'); $builder->where('ssn_news_tags_xref_video.items_id', $itemsid); $builder->where('ssn_news_tags_xref_video.active', '1'); $builder->where('ssn_news_tags_xref_video.trash', '0'); return $builder->get(); } public function get_tags_id_by_name($name) { $builder = $this->db->table('ssn_news_tags_video'); $builder->select('ssn_news_tags_video.id'); $builder->where('ssn_news_tags_video.name', $name); return $builder->get(); } public function get_artikel_by_tags($itemsid) { $builder = $this->db->table('ssn_news_tags_xref_video'); $builder->select('ssn_news_tags_xref_video.*, ssn_news_items_video.*'); $builder->join('ssn_news_items_video', 'ssn_news_items_video.id = ssn_news_tags_xref_video.items_id', 'left'); $builder->where('ssn_news_tags_xref_video.tag_id', $itemsid); $builder->where('ssn_news_tags_xref_video.active', '1'); $builder->where('ssn_news_tags_xref_video.trash', '0'); return $builder->get(); } //////////////////////////////////////////////////////////////// public function save_news_hits_video($id, $jenis = 1, $hits2) { if ($jenis == 1) { $hits = $this->db->table('ssn_news_items_video')->update($hits2, array('id' => $id)); } } public function save_hits_video($id, $jenis = 1, $data) { if ($jenis == 1) { $hits = $this->db->table('ssn_news_hits_video')->insert($data); } } }