Advertisement
kareelkun

logCI4

Oct 18th, 2021
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2. namespace App\Controllers;
  3. use CodeIgniter\Controller;
  4.  
  5. class aktiflog extends Controller
  6. {
  7.     public function __construct()
  8.     {
  9.         $this->session = session();
  10.         $this->db = \Config\Database::connect();
  11.         $this->log = model('App\Models\log');
  12.     }
  13.  
  14.     public function index()
  15.     {
  16.         $JumlahMaksimalDitampilkan=10;
  17.         $BarisLamaYangMauDihapus=0;
  18.         $logshow = $this->log->asObject()->where('log_userid',$_SESSION['user_login'])->orderBy('log_id','DESC')->find();
  19.         if(count($logshow)>$JumlahMaksimalDitampilkan){$BarisLamaYangMauDihapus=count($logshow)-10;}
  20.         echo 'Menampilkan semua data USERID untuk dihitung berapa jumlahnya (Diurutkan paling baru diatas)<br/>';
  21.         $noshow=0;
  22.         foreach($logshow as $logs){
  23.             $noshow++;
  24.             echo 'No.'.$noshow.' (ID'.$logs->log_id.' USERID'.$logs->log_userid.')<br/>';
  25.         }
  26.         echo '<br/>Jika data diatas jumlahnya lebih dari '.$JumlahMaksimalDitampilkan.', maka urutan selanjutnya akan dihapus<br/><br/><br/>';
  27.         $log = $this->log->asObject()->where('log_userid',$_SESSION['user_login'])->orderBy('log_id','ASC')->limit($BarisLamaYangMauDihapus)->find();
  28.         echo 'Data dibawah akan dihapus yang sudah diurutkan paling lama<br/>';
  29.         $nodel=$JumlahMaksimalDitampilkan;
  30.         foreach($log as $logs){
  31.             $nodel++;
  32.             echo 'No.'.$nodel.' (ID'.$logs->log_id.' USERID'.$logs->log_userid.')<br/>';
  33.         }
  34.     }
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement