Advertisement
gujil

class

Jun 20th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php  
  2. /**
  3. *
  4. */
  5. class mahasiswa
  6. {
  7.    
  8.     private $conn;
  9.  
  10.     function __construct()
  11.     {
  12.         $this->conn = new mysqli('localhost','root','','siketek');
  13.         if($this->conn){
  14.             return $this->conn;
  15.         }
  16.         return "DATABASE_CONNECTION_FAILED";
  17.     }
  18.  
  19.     public function detailHadir($id, $day){
  20.        
  21.         $sql = "SELECT h.id_hadir, h.tanggal_hadir, h.mulai_hadir, h.selesai_hadir, h.istirahat_hadir, h.sts_hadir FROM hadir h
  22.             JOIN detail_hadir d ON d.id_hadir=h.id_hadir
  23.             JOIN mahasiswa m ON m.id_maha=h.id_maha
  24.             JOIN user u ON u.id_user=m.id_user
  25.             WHERE u.id_user = ? AND WEEK(tanggal_hadir) = ? GROUP BY d.id_hadir ORDER BY tanggal_hadir ASC";
  26.             $pre_stmt = $this->conn->prepare($sql);
  27.  
  28.         for ($i=0; $i < count($day) ; $i++) {  
  29.             $pre_stmt->bind_param('is', $id, $day[$i]);
  30.             $pre_stmt->execute();      
  31.             $result = $pre_stmt->get_result() or die($this->conn->error);
  32.  
  33.             while($row = $result->fetch_assoc()){
  34.                 $rows[] = $row;
  35.             }
  36.         }
  37.  
  38.         return $rows;
  39.     }
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement