Advertisement
sriyanto

Modelalumni

Jul 5th, 2021 (edited)
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. Class Model_alumni extends CI_Model{
  4.    
  5.     function __construct()
  6.     {
  7.         parent::__construct();
  8.     }
  9.     public function tampil(){
  10.         return $this->db->get('alumni')->result();
  11.     }
  12.     public function insert($data){
  13.         $this->db->insert('alumni',$data);
  14.     }
  15.     public function update($data,$where){
  16.         $this->db->update('alumni',$data,$where);
  17.     }
  18.     public function get_by_id($id){
  19.         return $this->db->get_where('alumni',array('id'=>$id))->row();
  20.     }
  21.     public function getAllUser(){
  22.         return $this->db->get('alumni')->result_array();
  23.     }
  24.     public function hapusData($id){
  25.         $_id = $this->db->get_where('alumni',['id' => $id])->row();
  26.    $query=$this->db->delete('alumni',['id'=>$id]);
  27.    if($query){
  28.     unlink("./upload/ijazah/".$_id->foto1);
  29.     unlink("./upload/ijazah/".$_id->foto2);
  30.  
  31. }
  32.     }
  33.  
  34.     function simpan($data = array())
  35.     {
  36.         $jumlah = count($data);
  37.  
  38.         if ($jumlah > 0)
  39.         {
  40.             $this->db->insert_batch('alumni', $data);
  41.         }
  42.     }
  43.     function getAll()
  44.     {
  45.         $this->db->from('alumni'); //nama tabel harap disesuaikan dengan nama tabel milik sobat
  46.  
  47.         return $this->db->get();
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement