53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
use Codeigniter\HTTP\RequestInterface;
|
|
|
|
class ModelDarah extends Model
|
|
{
|
|
|
|
protected $db;
|
|
protected $request;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->db = \Config\Database::connect();
|
|
$this->request = \Config\Services::request();
|
|
}
|
|
|
|
protected $table = 'demam_berdarah';
|
|
protected $primaryKey = 'id';
|
|
protected $returnType = 'object';
|
|
protected $allowedFields = ['id', 'Tahun', 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
|
|
|
|
|
|
|
|
public function getDarah()
|
|
{
|
|
return $this->orderBy('id', 'DESC')->get();
|
|
}
|
|
|
|
public function getDarah2()
|
|
{
|
|
return $this->orderBy('Tahun', 'DESC')->get();
|
|
}
|
|
|
|
public function getDarah3()
|
|
{
|
|
return $this->orderBy('id', 'DESC')->limit(1)->get();
|
|
}
|
|
|
|
|
|
|
|
public function insert_darah($data)
|
|
{
|
|
return $this->db->table($this->table)->insert($data);
|
|
}
|
|
|
|
public function getById($id)
|
|
{
|
|
return $this->where(['id' => $id])->get();
|
|
}
|
|
}
|