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_goldarah(){ $q = "SELECT * FROM goldarah"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_goldarah(){ $fieldsAndValues = $this->getFieldsAndValues(); $this->db->insert('goldarah', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Simpan Data Berhasil'; $this->rhlib->insertRecordPublic('goldarah',$fieldsAndValues); }else{ $ret["success"]=false; $ret["msg"]= 'Simpan Data Gagal'; } return $ret; } function update_goldarah(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['idgoldarah'] = $_POST['idgoldarah']; $this->db->where('idgoldarah', $_POST['idgoldarah']); $this->db->update('goldarah', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('goldarah',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_goldarah(){ $where['idgoldarah'] = $_POST['idgoldarah']; $this->db->trans_begin(); $this->db->delete("goldarah",$where); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $return["success"]=false; $return["message"]="Hapus Data gagal"; } else { $this->db->trans_commit(); $return["success"]=true; $return["message"]="Hapus Data Berhasil"; $this->rhlib->deleteRecordPublic('goldarah',$where); } return $return; } function getFieldsAndValues(){ $dataArray = array( 'kdgoldarah'=> $_POST['kdgoldarah'], 'nmgoldarah'=> $_POST['nmgoldarah'], 'deskripsi'=> $_POST['deskripsi'], ); return $dataArray; } } ?>