Files
web-sekolah/application/models/Siswamodel.php
T
2026-06-26 13:37:55 +07:00

86 lines
2.0 KiB
PHP

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class SiswaModel extends CI_Model {
public function __construct()
{
parent::__construct();
$this->load->database();
}
// public function viewByNo($no_pendaftaran){
// $this->db->where('no_pendaftaran', $no_pendaftaran);
// $result = $this->db->get('v_rpt_trans_formulir')->row(); // Tampilkan data
// return $result;
// }
public function viewByNo($no_pendaftaran) {
$sql = "SELECT * FROM data_siswa
WHERE no_pendaftaran = ?
AND no_pendaftaran NOT IN (
SELECT no_pendaftaran FROM v_rpt_nilai_tes
)";
$query = $this->db->query($sql, array($no_pendaftaran));
$result = $query->row(); // Ambil hasil query
return $result;
}
public function viewByNo2($no_pendaftaran){
$this->db->where('no_pendaftaran', $no_pendaftaran);
$result = $this->db->get('v_rpt_data_pengumuman')->row(); // Tampilkan data
return $result;
}
//ambil data user
public function listing()
{
$this->db->select('*');
$this->db->from('nilai_tes');
$this->db->order_by('no_pendaftaran','desc');
$query = $this->db->get();
return $query->result();
}
//hitung get siswa
public function get_siswa()
{
$this->db->select('*');
$this->db->from('data_siswa');
$this->db->order_by('no_pendaftaran','desc');
$query = $this->db->get();
return $query->result();
}
//hitung total tes
public function total()
{
$this->db->select('COUNT(*) AS total');
$this->db->from('nilai_tes');
$this->db->order_by('no_pendaftaran','desc');
$query = $this->db->get();
return $query->row();
}
//tambah nilai
public function tambah($data)
{
$this->db->insert('nilai_tes', $data);
}
//fungsi delete
public function delete($data)
{
$this->db->where('no_pendaftaran', $data['no_pendaftaran']);
$this->db->delete('nilai_tes', $data);
}
//ubah status
public function edit($data)
{
$this->db->where('no_pendaftaran', $data['no_pendaftaran']);
$this->db->update('data_siswa', $data);
}
}