copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelProgram extends CI_Model {
|
||||
public function create($table, $data, $batch = false)
|
||||
{
|
||||
if($batch === false){
|
||||
$insert = $this->db->insert($table, $data);
|
||||
}else{
|
||||
$insert = $this->db->insert_batch($table, $data);
|
||||
}
|
||||
return $insert;
|
||||
}
|
||||
|
||||
public function update($table, $data, $pk, $id = null, $batch = false)
|
||||
{
|
||||
if($batch === false){
|
||||
$insert = $this->db->update($table, $data, array($pk => $id));
|
||||
}else{
|
||||
$insert = $this->db->update_batch($table, $data, $pk);
|
||||
}
|
||||
return $insert;
|
||||
}
|
||||
|
||||
public function delete($table, $data, $pk)
|
||||
{
|
||||
$this->db->where_in($pk, $data);
|
||||
return $this->db->delete($table);
|
||||
}
|
||||
|
||||
public function getData_Program($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('program');
|
||||
$this->db->order_by('NAMA_PROGRAM ASC');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('program');
|
||||
$this->db->where(['ID_PROGRAM' => $id]);
|
||||
$this->db->order_by('NAMA_PROGRAM ASC');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_LinkKlaimProgram_byPROGRAM($id){
|
||||
$this->db->select('*');
|
||||
$this->db->from('link_klaimprogram a');
|
||||
$this->db->join('program b','b.ID_PROGRAM=a.PROGRAM_ID');
|
||||
$this->db->where(['a.PROGRAM_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Program_byNAMA($id1, $id2=null){
|
||||
if ($id2 == null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('program');
|
||||
$this->db->where(['NAMA_PROGRAM' => $id1]);
|
||||
} else {
|
||||
$this->db->select('*');
|
||||
$this->db->from('program');
|
||||
$this->db->where(['NAMA_PROGRAM' => $id1]);
|
||||
$this->db->where('ID_PROGRAM!=', $id2);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user