<?php

namespace App\Models;

use CodeIgniter\Model;

class Tingkat_model extends Model
{
    var $table = 'tingkat';
    public function __construct()
    {
        parent::__construct();
    }

    public function get_all_tingkat()
    {
        $query = $this->db->table($this->table)
            ->get();
        return $query->getResult();
    }


    public function get_by_id($id)
    {
        $query =  $this->db->table($this->table)
            ->where('id', $id)
            ->get();
        return $query->getRow();
    }
    public function get_where($where)
    {
        $query =  $this->db->table($this->table)
            ->where($where)
            ->get();
        return $query->getRow();
    }
    public function tingkat_add($data)
    {
        $query = $this->db->table($this->table)->insert($data);
        return $this->db->insertID();
    }
    public function update_status($where)
    {

        $cekdata = $this->db->table($this->table)
            ->update(['status' => 'tidak'], $where);
        return $cekdata;
    }


    public function tingkat_update($where, $data)
    {
        $this->db->table($this->table)->update($data, $where);
        return $this->db->affectedRows();
    }

    public function delete_by_id($id)
    {
        $this->db->table($this->table)->delete(array('id' => $id));
    }
}
