load->library('session'); $this->load->library('rhlib'); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_hari(){ $q = "SELECT * FROM hari"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_hari(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('hari',$dataArray); return $ret; } function update_hari(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idhari', $_POST['idhari']); $this->db->update('hari', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_hari(){ $where['idhari'] = $_POST['idhari']; $ret = $this->rhlib->deleteRecord('hari',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdhari'=> $_POST['kdhari'], 'nmhari'=> $_POST['nmhari'], 'deskripsi'=> $_POST['deskripsi'], ); return $dataArray; } } ?>