341 lines
14 KiB
PHP
341 lines
14 KiB
PHP
<?php
|
|
class M_vic extends CI_Model
|
|
{
|
|
|
|
|
|
public function getCombo1Options()
|
|
{
|
|
// Lakukan query untuk mengambil opsi combo box 1 dari database
|
|
$query = $this->db->get('normalisasi');
|
|
return $query->result_array();
|
|
}
|
|
|
|
public function getCombo2Options()
|
|
{
|
|
// Lakukan query untuk mengambil opsi combo box 2 dari database
|
|
$query = $this->db->get('normalisasi');
|
|
return $query->result_array();
|
|
}
|
|
|
|
public function getFilteredData($selectedValue1, $selectedValue2)
|
|
{
|
|
// Lakukan query untuk mengambil data dari database berdasarkan pilihan combo box
|
|
$this->db->select('*');
|
|
$this->db->from('normalisasi');
|
|
$this->db->where('alternatif_id', $selectedValue1);
|
|
$this->db->where('tahun', $selectedValue2);
|
|
$query = $this->db->get();
|
|
|
|
return $query->result_array();
|
|
}
|
|
|
|
// general
|
|
public function selecttahun($where = '')
|
|
{
|
|
return $this->db->query("select DISTINCT tahun from $where");
|
|
}
|
|
|
|
public function edit_data($where, $table)
|
|
{
|
|
return $this->db->get_where($table, $where);
|
|
}
|
|
|
|
public function portal_login($where, $table)
|
|
{
|
|
$db2 = $this->load->database('portal', true);
|
|
return $db2->get_where($table, $where);
|
|
}
|
|
|
|
public function selectda($where = '')
|
|
{
|
|
return $this->db->query("SELECT alternatif.alternatif_kode, alternatif.alternatif_nama, kriteria.c1c, kriteria.c2c, kriteria.c3c, kriteria.tahun FROM `alternatif`INNER JOIN kriteria
|
|
ON alternatif.alternatif_id = kriteria.alternatif_id");
|
|
}
|
|
public function deletekrit($where = '')
|
|
{
|
|
return $this->db->query();
|
|
}
|
|
public function selectbaru($where = '')
|
|
{
|
|
return $this->db->query("SELECT alternatif.alternatif_kode, alternatif.alternatif_nama, normalisasi.c1c, normalisasi.c2c, normalisasi.c3c, normalisasi.tahun FROM `alternatif`INNER JOIN normalisasi
|
|
ON alternatif.alternatif_id = normalisasi.alternatif_id");
|
|
}
|
|
public function selectkritalt($where = '')
|
|
{
|
|
return $this->db->query("SELECT alternatif.alternatif_kode, alternatif.alternatif_nama, kriteria.c1c, kriteria.c2c, kriteria.c3c, kriteria.tahun FROM `alternatif`INNER JOIN kriteria
|
|
ON alternatif.alternatif_id = kriteria.alternatif_id");
|
|
}
|
|
public function selectya($tahun = '')
|
|
{
|
|
return $this->db->query("SELECT alternatif.alternatif_id,alternatif.alternatif_kode, alternatif.alternatif_nama, normalisasi.c1c, normalisasi.c2c, normalisasi.c3c, normalisasi.tahun FROM `alternatif`INNER JOIN normalisasi
|
|
ON alternatif.alternatif_id = normalisasi.alternatif_id $tahun");
|
|
}
|
|
public function selectkrtitahun($tahun = '')
|
|
{
|
|
return $this->db->query("SELECT alternatif.alternatif_id,alternatif.alternatif_kode, alternatif.alternatif_nama, kriteria.c1c, kriteria.c2c, kriteria.c3c, kriteria.tahun FROM `alternatif`INNER JOIN kriteria
|
|
ON alternatif.alternatif_id = kriteria.alternatif_id $tahun");
|
|
}
|
|
public function selecttinggi($tahun = '')
|
|
{
|
|
return $this->db->query("SELECT predikat.alternatif_id FROM predikat INNER JOIN kriteria ON predikat.alternatif_id=kriteria.alternatif_id WHERE hasil='Sangat Rawan' $tahun");
|
|
}
|
|
public function selectal($tahun = '')
|
|
{
|
|
return $this->db->query("SELECT * FROM alternatif INNER JOIN kriteria ON alternatif.alternatif_id=kriteria.alternatif_id where tahun=2019");
|
|
}
|
|
public function selectrendah($tahun = '')
|
|
{
|
|
return $this->db->query("SELECT predikat.alternatif_id FROM predikat INNER JOIN kriteria ON predikat.alternatif_id=kriteria.alternatif_id WHERE hasil='Aman' $tahun");
|
|
}
|
|
public function selectsedang($tahun = '')
|
|
{
|
|
return $this->db->query("SELECT predikat.alternatif_id FROM predikat INNER JOIN kriteria ON predikat.alternatif_id=kriteria.alternatif_id WHERE hasil='Rawan' $tahun");
|
|
}
|
|
|
|
public function selectcount($where = '')
|
|
{
|
|
return $this->db->query("SELECT COUNT(DISTINCT(alternatif_nama)) as tot from $where");
|
|
}
|
|
//select max avg min
|
|
public function selectMAM($where = '')
|
|
{
|
|
return $this->db->query("SELECT MAX(c1c),MAX(c2c),MAX(c3c),AVG(c1c),AVG(c2c),AVG(c3c),MIN(c1c),MIN(c2c),MIN(c3c) from $where");
|
|
}
|
|
public function selectMAMAM($where = '')
|
|
{
|
|
return $this->db->query("SELECT alternatif_id,c1c,c2c,c3c,tahun,MAX(c1c),MAX(c2c),MAX(c3c),AVG(c1c),AVG(c2c),AVG(c3c),MIN(c1c),MIN(c2c),MIN(c3c) from $where");
|
|
}
|
|
public function selectMax($where = '')
|
|
{
|
|
return $this->db->query("SELECT MAX(c1c),MAX(c2c),MAX(c3c) from $where");
|
|
}
|
|
public function selectAvg($where = '')
|
|
{
|
|
return $this->db->query("SELECT AVG(c1c),AVG(c2c),AVG(c3c) from $where");
|
|
}
|
|
public function selectMin($where = '')
|
|
{
|
|
return $this->db->query("SELECT MIN(c1c),MIN(c2c),MIN(c3c) from $where");
|
|
}
|
|
|
|
public function get_data($table)
|
|
{
|
|
return $this->db->get($table);
|
|
}
|
|
public function get_datkrit($table)
|
|
{
|
|
return $this->db->query("SELECT * From kriteria");
|
|
}
|
|
public function get_datang($where)
|
|
{
|
|
return $this->db->query("SELECT * From $where");
|
|
}
|
|
|
|
public function insert_data($data, $table)
|
|
{
|
|
$this->db->insert($table, $data);
|
|
}
|
|
|
|
public function update_data($where, $data, $table)
|
|
{
|
|
$this->db->where($where);
|
|
$this->db->update($table, $data);
|
|
}
|
|
|
|
public function delete_data($where, $table)
|
|
{
|
|
$this->db->where($where);
|
|
$this->db->delete($table);
|
|
}
|
|
|
|
public function get_data_order($order, $column, $table)
|
|
{
|
|
$this->db->order_by($column, $order);
|
|
return $this->db->get($table);
|
|
}
|
|
|
|
public function get_group($table, $group)
|
|
{
|
|
return $this->db->query("SELECT * FROM $table group by $group");
|
|
}
|
|
|
|
public function get_group_visitor($table, $group, $date)
|
|
{
|
|
return $this->db->query("SELECT * FROM $table WHERE date(time_visit)='$date' group by $group");
|
|
}
|
|
// end general
|
|
|
|
// cms
|
|
public function get_posts($post_status)
|
|
{
|
|
$this->db->order_by('post_id', 'desc');
|
|
$this->db->where(array('post_status' => $post_status));
|
|
return $this->db->get('tbl_posts');
|
|
}
|
|
|
|
public function get_posts_paging($post_status, $sampai, $dari)
|
|
{
|
|
$this->db->order_by('post_id', 'desc');
|
|
$this->db->where(array('post_status' => $post_status));
|
|
return $this->db->get('tbl_posts', $sampai, $dari);
|
|
}
|
|
|
|
public function search($keyword)
|
|
{
|
|
//$this->db->like('post_content',$keyword);
|
|
$this->db->like(array('post_tittle' => $keyword, 'post_content' => $keyword));
|
|
return $query = $this->db->get('tbl_posts');
|
|
}
|
|
|
|
public function get_search($post_status, $search)
|
|
{
|
|
$this->db->order_by('post_id', 'desc');
|
|
$this->db->where(array('post_status' => $post_status, 'post_tittle' => $search, 'post_content' => $search));
|
|
return $this->db->get('tbl_posts');
|
|
}
|
|
|
|
public function get_search_paging($search, $sampai, $dari)
|
|
{
|
|
$this->db->order_by('post_id', 'desc');
|
|
$this->db->like(array('post_tittle' => $search, 'post_content' => $search));
|
|
return $this->db->get('tbl_posts', $sampai, $dari);
|
|
}
|
|
|
|
public function get_kategori_paging($kategori, $sampai, $dari)
|
|
{
|
|
// $this->db->order_by('post_id', 'desc');
|
|
// $this->db->where(array('post_kategori'=> $kategori));
|
|
return $this->db->query("SELECT * FROM tbl_posts,tbl_kategori,tbl_taxonomy WHERE tbl_taxonomy.taxonomy='post_kategori' AND tbl_taxonomy.taxonomy_child=tbl_kategori.kategori_id AND tbl_kategori.kategori_id=$kategori AND tbl_posts.post_id=tbl_taxonomy.taxonomy_parent AND tbl_posts.post_status = 'Publish' ORDER BY tbl_posts.post_id DESC LIMIT $dari,$sampai");
|
|
// return $this->db->get('tbl_posts',$sampai,$dari);
|
|
}
|
|
|
|
public function get_tag_paging($tag, $sampai, $dari)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_posts,tbl_tag,tbl_taxonomy WHERE tbl_taxonomy.taxonomy='post_tag' AND tbl_taxonomy.taxonomy_child=tbl_tag.tag_id AND tbl_tag.tag_id=$tag AND tbl_posts.post_id=tbl_taxonomy.taxonomy_parent AND tbl_posts.post_status = 'Publish' ORDER BY tbl_posts.post_id DESC LIMIT $dari,$sampai");
|
|
}
|
|
|
|
public function get_author_paging($author, $sampai, $dari)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_posts,tbl_kategori,tbl_taxonomy WHERE tbl_taxonomy.taxonomy='post_kategori' AND tbl_taxonomy.taxonomy_child=tbl_kategori.kategori_id AND tbl_posts.post_author='$author' AND tbl_posts.post_id=tbl_taxonomy.taxonomy_parent AND tbl_posts.post_status = 'Publish' ORDER BY tbl_posts.post_id DESC LIMIT $dari,$sampai");
|
|
}
|
|
|
|
public function get_post_limit($post_status, $limit)
|
|
{
|
|
$this->db->limit($limit);
|
|
$this->db->order_by('post_id', 'desc');
|
|
$this->db->where(array('post_status' => $post_status));
|
|
return $this->db->get('tbl_posts');
|
|
}
|
|
|
|
public function get_post_limit2($post_status, $limit, $idkategori)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_taxonomy,tbl_kategori,tbl_posts WHERE tbl_taxonomy.taxonomy_child='$idkategori' AND tbl_taxonomy.taxonomy='post_kategori' AND tbl_taxonomy.taxonomy_child=tbl_kategori.kategori_id AND tbl_taxonomy.taxonomy_parent=tbl_posts.post_id AND post_status = '$post_status' ORDER BY post_id DESC LIMIT $limit");
|
|
}
|
|
|
|
public function get_post_kategori($id_post)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_taxonomy,tbl_kategori WHERE tbl_taxonomy.taxonomy_parent='$id_post' AND tbl_taxonomy.taxonomy='post_kategori' AND tbl_taxonomy.taxonomy_child=tbl_kategori.kategori_id ");
|
|
}
|
|
|
|
public function get_update_baca($id_post)
|
|
{
|
|
return $this->db->query("UPDATE tbl_posts SET post_baca = post_baca + 1 WHERE post_id = '$id_post'");
|
|
}
|
|
|
|
public function post_in_kategori($id_kategori)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_taxonomy,tbl_kategori,tbl_posts WHERE tbl_taxonomy.taxonomy_child='$id_kategori' AND tbl_taxonomy.taxonomy='post_kategori' AND tbl_taxonomy.taxonomy_child=tbl_kategori.kategori_id AND tbl_taxonomy.taxonomy_parent=tbl_posts.post_id");
|
|
}
|
|
|
|
public function get_post_tag($id_post)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_taxonomy,tbl_tag WHERE tbl_taxonomy.taxonomy_parent='$id_post' AND tbl_taxonomy.taxonomy='post_tag' AND tbl_taxonomy.taxonomy_child=tbl_tag.tag_id ");
|
|
}
|
|
|
|
public function post_in_tag($id_tag)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_taxonomy,tbl_tag,tbl_posts WHERE tbl_taxonomy.taxonomy_child='$id_tag' AND tbl_taxonomy.taxonomy='post_tag' AND tbl_taxonomy.taxonomy_child=tbl_tag.tag_id AND tbl_taxonomy.taxonomy_parent=tbl_posts.post_id");
|
|
}
|
|
|
|
public function post_in_author($id_author)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_taxonomy,tbl_kategori,tbl_posts WHERE tbl_posts.post_author='$id_author' AND tbl_taxonomy.taxonomy='post_kategori' AND tbl_taxonomy.taxonomy_child=tbl_kategori.kategori_id AND tbl_taxonomy.taxonomy_parent=tbl_posts.post_id");
|
|
}
|
|
|
|
public function get_post_detail($id_post)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_posts,tbl_pegawai WHERE tbl_posts.post_author=tbl_pegawai.peg_user AND tbl_posts.post_id='$id_post'");
|
|
}
|
|
|
|
// function get_update_baca($id_post){
|
|
// return $this->db->query("UPDATE tbl_posts SET post_baca = post_baca + 1 WHERE post_id = '$id_post'");
|
|
// }
|
|
|
|
public function get_update_media($id_media)
|
|
{
|
|
return $this->db->query("UPDATE tbl_media SET media_baca = media_baca + 1 WHERE media_id = '$id_media'");
|
|
}
|
|
// end cms
|
|
|
|
// get options
|
|
public function get_option($option_name)
|
|
{
|
|
$query = $this->db->query("SELECT option_value FROM tbl_options WHERE option_name='$option_name'")->row();
|
|
return $query->option_value;
|
|
}
|
|
// end get option
|
|
|
|
// menu
|
|
public function get_menu_mother()
|
|
{
|
|
//return $this->db->query("SELECT * FROM tbl_menu WHERE menu_mother != '0' AND menu_name='0' AND menu_url='0' AND menu_parent='0' AND menu_sort='0'");
|
|
return $this->db->query("SELECT * FROM tbl_menu WHERE menu_mother != '0' AND menu_name!='0' AND menu_url!='0' AND menu_parent='0' AND menu_sort='0'");
|
|
}
|
|
|
|
public function get_menu_item($mother)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_menu WHERE menu_mother = '$mother' AND menu_name!='0' AND menu_parent='0' ORDER BY menu_sort ASC");
|
|
}
|
|
|
|
public function get_all_menu_item($mother)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_menu WHERE menu_mother = '$mother' AND menu_name!='0' ORDER BY menu_sort ASC");
|
|
}
|
|
// end menu
|
|
|
|
// visitor
|
|
public function get_pageview($date)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_visitor WHERE date(time_visit)='$date'");
|
|
}
|
|
|
|
public function get_visitor($date)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_visitor WHERE date(time_visit)='$date' group by user_ip");
|
|
}
|
|
|
|
public function get_ftvisitor($date)
|
|
{
|
|
return $this->db->query("SELECT * FROM tbl_visitor WHERE date(time_visit)='$date' AND user_ip not in(select user_ip from tbl_visitor)");
|
|
}
|
|
|
|
public function page_view($date)
|
|
{
|
|
return $this->db->query("select count(page) as page_view, page from tbl_visitor WHERE date(time_visit)='$date' group by page ORDER BY page_view desc");
|
|
}
|
|
|
|
public function get_referrer($date)
|
|
{
|
|
return $this->db->query("select distinct user_referrer from tbl_visitor WHERE date(time_visit)='$date' AND user_referrer!=''");
|
|
}
|
|
|
|
public function panggil_db()
|
|
{
|
|
//$db = mysqli_connect("localhost", "kerj_pengguna", "katasandi");
|
|
$db = mysqli_connect("localhost", "root", "");
|
|
mysqli_select_db($db, "db_unimal_simail");
|
|
return $db;
|
|
}
|
|
|
|
}
|