Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Biodata_model extends CI_Model
- {
- private $_table = "calon_siswa";
- public $biodata_id;
- public $nama;
- public $alamat;
- public $jenis_kelamin;
- public $agama;
- public $sekolah_asal;
- public $sekolah_tujuan;
- public function rules()
- {
- return [
- ['field' => 'nama',
- 'label' => 'Nama',
- 'rules' => 'required'],
- ['field' => 'alamat',
- 'label' => 'Alamat',
- 'rules' => 'required'],
- ['field' => 'jenis_kelamin',
- 'label' => 'Jenis Kelamin',
- 'rules' => 'required'],
- ['field' => 'agama',
- 'label' => 'Agama',
- 'rules' => 'required'],
- ['field' => 'sekolah_asal',
- 'label' => 'Sekolah Asal',
- 'rules' => 'required'],
- ['field' => 'sekolah_tujuan',
- 'label' => 'Sekolah Tujuan',
- 'rules' => 'required']
- ];
- }
- public function getAll()
- {
- return $this->db->get($this->_table)->result();
- }
- public function getById($id)
- {
- return $this->db->get_where($this->_table, ["biodata_id" => $id])->row();
- }
- public function save()
- {
- $post = $this->input->post();
- $this->biodata_id = uniqid();
- $this->nama = $post["nama"];
- $this->alamat = $post["alamat"];
- $this->jenis_kelamin = $post["jenis_kelamin"];
- $this->agama = $post["agama"];
- $this->sekolah_asal = $post["sekolah_asal"];
- $this->sekolah_tujuan = $post["sekolah_tujuan"];
- $this->db->insert($this->_table, $this);
- }
- public function update()
- {
- $post = $this->input->post();
- $this->biodata_id = $post["biodata_id"];
- $this->nama = $post["nama"];
- $this->alamat = $post["alamat"];
- $this->jenis_kelamin = $post["jenis_kelamin"];
- $this->agama = $post["agama"];
- $this->sekolah_asal = $post["sekolah_asal"];
- $this->sekolah_tujuan = $post["sekolah_tujuan"];
- $this->db->update($this->_table, $this, array('biodata_id' => $post['biodata_id']));
- }
- public function delete($id)
- {
- return $this->db->delete($this->_table, array("biodata_id" => $id));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment