52 lines
1.0 KiB
PHP
52 lines
1.0 KiB
PHP
<?php
|
|
class M_pasien extends CI_Model
|
|
{
|
|
function list_data($id_kategori="")
|
|
{
|
|
$q = "SELECT p.id, p.nama, p.tempat_lahir, p.tgl_lahir, p.jenkel, p.no_telp, p.alamat, p.ortu, p.id_kategori_pasien,
|
|
p.created_at, p.updated_at, k.nama kategori_pasien
|
|
FROM pasien p
|
|
LEFT JOIN kategori_pasien k ON k.id = p.id_kategori_pasien
|
|
WHERE p.id is not null
|
|
";
|
|
|
|
if ($id_kategori!="") {
|
|
$q .= " AND p.id_kategori_pasien = '$id_kategori' ";
|
|
}
|
|
$q .= "ORDER BY p.created_at DESC ";
|
|
|
|
$query= $this->db->query($q);
|
|
return $query;
|
|
}
|
|
|
|
function get_all()
|
|
{
|
|
$this->db->select('id, nama');
|
|
$this->db->from('pasien');
|
|
$this->db->order_by("nama", "asc");
|
|
return $this->db->get();
|
|
}
|
|
|
|
function insert($data, $table)
|
|
{
|
|
$this->db->insert($table, $data);
|
|
}
|
|
|
|
function delete($where, $table)
|
|
{
|
|
$this->db->where($where);
|
|
$this->db->delete($table);
|
|
}
|
|
|
|
function edit($where, $table)
|
|
{
|
|
return $this->db->get_where($table, $where);
|
|
}
|
|
|
|
function update($where, $data, $table)
|
|
{
|
|
$this->db->where($where);
|
|
$this->db->update($table, $data);
|
|
}
|
|
}
|