load->library('session'); $this->load->library('rhlib'); } function autoNumberPub($column,$tbl){ $KEDUA= $this->load->database('second', TRUE); $q = "SELECT max(".$column.")+1 as max FROM ".$tbl."" ; $query = $KEDUA->query($q); $max = ''; if ($query->num_rows() != 0) { $row = $query->row(); $max=$row->max; } if ($max == null){ $max=0; } return $max; } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_jusm(){ $q = "SELECT * FROM jusm ORDER BY kdjnsusm"; $this->rhlib->jsonFromQueryWLimit2($q); } function insert_jusm(){ $dataArray = array( 'idjnsusm'=> $this->autoNumberPub('idjnsusm','jusm'), 'kdjnsusm'=> $_POST['kdjnsusm'], 'nmjnsusm'=> $_POST['nmjnsusm'], 'deskripsi'=> $_POST['deskripsi'] ); return $this->rhlib->insertRecordPublic('jusm',$dataArray); } function update_jusm(){ $dataArray = array( 'kdjnsusm'=> $_POST['kdjnsusm'], 'nmjnsusm'=> $_POST['nmjnsusm'], 'deskripsi'=> $_POST['deskripsi'] ); $where['idjnsusm'] = $_POST['idjnsusm']; return $this->rhlib->updateRecordPublic('jusm',$dataArray,$where); } function delete_jusm(){ $where['idjnsusm'] = $_POST['idjnsusm']; return $this->rhlib->deleteRecordPublic('jusm',$where); } } ?>